Part Number Hot Search : 
0FB00 DG302 BD6222HF F0810 G1562 C574P C574P CD407
Product Description
Full Text Search
 

To Download SN8P2711 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  SN8P2711 8-bit micro-controller sonix technology co., ltd page 1 version 1.4 SN8P2711 user?s manual version 1.4 s s o o n n i i x x 8 8 - - b b i i t t m m i i c c r r o o - - c c o o n n t t r r o o l l l l e e r r sonix reserves the right to make change without further notice to any products herein to improve reliability, function or desig n. sonix does not assume any liability arising out of the application or use of an y product or circuit described her ein; neither does it convey a ny license under its patent rights nor the rights of others. sonix products are not designed, intended, or authorized for us as components in systems inten ded, for surgical implant into the body, or other applications intended to suppor t or sustain life, or for any other application in which the fai lure of the sonix product could create a situation where personal injury or death may occu r. should buyer purchase or use sonix products for any such uni ntended or unauthorized application. buyer shall indemnify and hold sonix and its officers, employees, subs idiaries, affiliates and distri butors harmless against all claims, cost, damages, and expenses, and re asonable attorney fees arising out of, dire ctly or indirectly, any claim of pers onal injury or death associated with such unintended or unauthorized use even if such claim alleges that sonix was negligent regarding the design or manufacture of the part.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 2 version 1.4 amendent history version date description ver 0.1 nov. 2004 first issue. ver 0.2 dec. 2004 1. add sn8pev2711 item. sn8pev2 711 is with 56*8 bits ram and poor esd. SN8P2711 is with 64*8 bits ram and pe rfect esd. sn8pev2711 is engineering version. 2. modify adc chapter. 3. modify development chapter. 4. add internal 16mhz oscillator rc type characteristic. ver 0.3 jan 2005 1. modify lcd code options. lv d0 > lvd_l, lvd_1 > lv d_m, lvd2 > lvd_h. 2. in SN8P2711 otp programming by easy wri ter, the crystal of ice must be 16mhz. 3. connect easy writer to ice through a 60-pin cable which shipping with easy writer. 4. remove sn8pev2711 description. ver 0.4 jan 2005 modify otp programming pin mapping table ver 1.0 may 2005 1. modify p102 the second line of the first sentence ?c0ms? to ??cmos?. 2. modify p102 ?vhs[1:0] is 01? to ?vhs[1:0] is 10?. 3. modify p102 ?vhs[1:0] is lower than vd d? to ? vhs[1:0] is higher than vdd?. 4. modify chapter9 adc converter. ver 1.1 may 2005 1. modify p53 ?note? description. 2. modify all ?verfh? to ?vrefh?. 3. modify p102 bit[7] description. jun 2005 modify p104 internal a dc reference 3v setting example. july 2005 1. modify p77 t0m register (add tc1x8). aug 2005 1. add p120 note. use m2ide v1 .06 (or after version) to simulation. 2. add p120 note. use 16m hz crysta l to simulation internal 16m rc. 3. add p120 note. use 16m hz crysta l to programming with ez-writer. 4. modify p108 internal hihg rc. ver 1.2 nov.2005 1. add brown-out reset circuit. ver 1.3 dec 2005 1. add adc current. 2. modify topr value. 3. modify brown-out reset description 4. remove power consumption(pc) 5. modify m2ide 1.07 6. remove high clock32k mode 7. add fcpu limitation by noise filter enable. 8. modify electrical characteristic. ver 1.4 feb 2007 1. add marking definition. 2. modify electrical characteristic. 3. modify rst/p0.4/vpp pin discription.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 3 version 1.4 table of content amendent history........................................................................................................................ ........ 2 1 1 1 product overview............................................................................................................... .......... 7 1.1 features ................................................................................................................... ..................... 7 1.2 system block diagram .......................................................................................................... 8 1.3 pin assignment ..................................................................................................................... ...... 9 1.4 pin descriptions................................................................................................................... .... 10 1.5 pin circuit diagrams............................................................................................................. 11 2 2 2 central processor unit (cpu) .............................................................................................. 13 2.1 memory map............................................................................................................................ ... 13 2.1.1 program memory (rom) ................................................................................................. 13 2.1.1.1 reset vector (0000h) .................................................................................................. 1 4 2.1.1.2 interrupt vector (0008h)......................................................................................... 15 2.1.1.3 look-up table description.................................................................................... 17 2.1.1.4 jump table description ........................................................................................... 19 2.1.1.5 checksum calculation........................................................................................... 21 2.1.2 code option table ........................................................................................................... 22 2.1.3 data memory (ram)........................................................................................................... 23 2.1.4 system register................................................................................................................ .24 2.1.4.1 system register table ............................................................................................ 24 2.1.4.2 system register description ............................................................................... 24 2.1.4.3 bit definition of system register....................................................................... 25 2.1.4.4 accumulator ............................................................................................................ ... 26 2.1.4.5 program flag ........................................................................................................... .... 27 2.1.4.6 program counter....................................................................................................... 2 8 2.1.4.7 y, z registers......................................................................................................... ........ 31 2.1.4.8 r registers ............................................................................................................ ......... 32 2.2 addressing mode .................................................................................................................... 33 2.2.1 immediate addressing mode....................................................................................... 33 2.2.2 directly addressing mode .......................................................................................... 33 2.2.3 indirectly addressing mode ...................................................................................... 33 2.3 stack operation...................................................................................................................... 34 2.3.1 overview ....................................................................................................................... ....... 34 2.3.2 stack registers ................................................................................................................ .35 2.3.3 stack operation example............................................................................................. 36 3 3 3 reset .......................................................................................................................... ........................... 37
SN8P2711 8-bit micro-controller sonix technology co., ltd page 4 version 1.4 3.1 overview................................................................................................................... .................. 37 3.2 power on reset......................................................................................................................... 3 8 3.3 watchdog reset...................................................................................................................... 38 3.4 brown out reset ..................................................................................................................... 39 3.4.1 brown out description ................................................................................................. 39 3.4.2 the system operating voltage decsription........................................................ 40 3.4.3 brown out reset improvement.................................................................................. 40 3.5 external reset ........................................................................................................................ 43 3.6 external reset circuit ....................................................................................................... 43 3.6.1 simply rc reset circuit ........................................................................................................ ... 43 3.6.2 diode & rc reset circuit ....................................................................................................... .44 3.6.3 zener diode reset circuit ...................................................................................................... .. 44 3.6.4 voltage bias reset circuit..................................................................................................... ... 45 3.6.5 external reset ic.............................................................................................................. ........ 46 4 4 4 system clock ................................................................................................................... ............... 47 4.1 overview................................................................................................................... .................. 47 4.2 clock block diagram .......................................................................................................... 47 4.3 oscm register ....................................................................................................................... .... 48 4.4 system high clock ................................................................................................................. 49 4.4.1 internal high rc............................................................................................................... 49 4.4.2 external high clock...................................................................................................... 49 4.4.2.1 crystal/ceramic........................................................................................................ . 50 4.4.2.2 rc..................................................................................................................... .................... 50 4.4.2.3 external clock signal........................................................................................... 51 4.5 system low clock .................................................................................................................. 52 4.5.1 system clock measurement ........................................................................................ 53 5 5 5 system operation mode .......................................................................................................... .54 5.1 overview................................................................................................................... .................. 54 5.2 system mode switching example ................................................................................... 55 5.3 wakeup ..................................................................................................................... .................... 57 5.3.1 overview ....................................................................................................................... ....... 57 5.3.2 wakeup time.................................................................................................................... .... 57 6 6 6 interrupt...................................................................................................................... ..................... 58 6.1 overview................................................................................................................... .................. 58 6.2 inten interrupt enable register................................................................................... 59 6.3 intrq interrupt request register ................................................................................ 60 6.4 gie global interrupt operation .................................................................................... 61 6.5 push, pop routine .................................................................................................................... 62
SN8P2711 8-bit micro-controller sonix technology co., ltd page 5 version 1.4 6.6 int0 (p0.0) interrupt operation......................................................................................... 63 6.7 int1 (p0.1) interrupt operation......................................................................................... 65 6.8 tc0 interrupt operation..................................................................................................... 66 6.9 tc1 interrupt operation..................................................................................................... 67 6.10 adc interrupt operation ................................................................................................... 69 6.11 multi-interrupt operation............................................................................................... 70 7 7 7 i/o port ....................................................................................................................... ......................... 71 7.1 i/o port mode ........................................................................................................................... .. 71 7.2 i/o pull up register ................................................................................................................ 72 7.3 i/o port data register .......................................................................................................... 73 7.4 port 4 adc share pin............................................................................................................... 74 8 8 8 timers ......................................................................................................................... ......................... 78 8.1 watchdog timer...................................................................................................................... 78 8.2 timer/counter 0 (tc0) ............................................................................................................ 81 8.2.1 overview ....................................................................................................................... ....... 81 8.2.2 tc0m mode register ........................................................................................................ 82 8.2.3 tc1x8, tc0x8, tc0gn flags .............................................................................................. 83 8.2.4 tc0c counting register ................................................................................................ 83 8.2.5 tc0r auto-load register .............................................................................................. 85 8.2.6 tc0 clock frequency ou tput (buzzer) .................................................................. 86 8.2.7 tc0 timer operation sequence .................................................................................. 87 8.3 timer/counter 1 (tc1) ............................................................................................................ 90 8.3.1 overview ....................................................................................................................... ....... 90 8.3.2 tc1m mode register ........................................................................................................ 91 8.3.3 tc1x8 flag..................................................................................................................... ....... 91 8.3.4 tc1c counting register ................................................................................................ 92 8.3.5 tc1r auto-load register .............................................................................................. 94 8.3.6 tc1 clock frequency ou tput (buzzer) .................................................................. 95 8.3.7 tc1 timer operation sequence .................................................................................. 96 8.4 pwm mode ........................................................................................................................... ......... 98 8.4.1 overview ....................................................................................................................... ....... 98 8.4.2 tcnirq and pwm duty........................................................................................................... 9 9 8.4.3 pwm duty with tcnr changing ........................................................................................... 100 8.4.4 pwm program example ................................................................................................ 101 9 9 9 5+1 channel analog to digital converter............................................................... 102 9.1 overview................................................................................................................... ................ 102 9.2 adm register ....................................................................................................................... .... 103 9.3 adr registers...................................................................................................................... .... 104
SN8P2711 8-bit micro-controller sonix technology co., ltd page 6 version 1.4 9.4 adb registers...................................................................................................................... .... 105 9.5 p4con registers ..................................................................................................................... 1 06 9.6 vrefh registers ..................................................................................................................... 1 07 9.7 adc converting time .......................................................................................................... 108 9.8 adc routine example.......................................................................................................... 109 9.9 adc circuit ........................................................................................................................ ....... 111 1 1 1 0 0 0 instruction table .............................................................................................................. ... 112 1 1 1 1 1 1 electrical characteristic ............................................................................................ 113 11.1 absolute maximum rating .............................................................................................. 113 11.2 electrical characteristic............................................................................................. 113 1 1 1 2 2 2 development tool version ............................................................................................. 116 12.1 ice (i n c ircuit e mulation )......................................................................................................... 116 12.2 otp writer ......................................................................................................................... ....... 116 12.3 sn8ide .................................................................................................................... ...................... 116 12.4 SN8P2711 ev kit ......................................................................................................................... 117 12.4.1 pcb description .............................................................................................................. 11 7 12.4.2 SN8P2711 ev kit connect to sn8ice 2k..................................................................... 119 12.5 transition board for otp programming ................................................................. 120 12.5.1 SN8P2711 v3 transition board .................................................................................... 120 12.5.2 SN8P2711 mp028a transition bo ard for ez/mpez writer ................................. 121 12.5.3 SN8P2711 mp028a connect to ez_mp writer.......................................................... 122 12.5.4 SN8P2711 mp028a connect to ez writer.................................................................. 122 12.5.5 SN8P2711 v3 connect to ez writer ........................................................................... 123 12.5.6 SN8P2711 v3 connect to ez_mp writer.................................................................... 123 12.6 otp programming pin .......................................................................................................... 124 12.6.1 easy writer transition board socket pin assignment .................................. 124 12.6.2 programming pin mapping:........................................................................................ 125 1 1 1 3 3 3 package information ......................................................................................................... 126 13.1 p-dip 14 pin ............................................................................................................................ ...... 126 13.2 sop 14 pin............................................................................................................................ ......... 127 13.3 ssop 16 pin............................................................................................................................ ....... 128
SN8P2711 8-bit micro-controller sonix technology co., ltd page 7 version 1.4 1 1 1 product overview 1.1 features ) features selection table timer pwm chip rom ram stack tc0 tc1 i/o adc green mode buzzer wakeup pin no. package SN8P2711 1k*16 64 4 v v 12 5+1 ch v 2 5 p-dip 14/sop 14/ssop 16 ? memory configuration ? 5+1 channel 12-bit adc. otp rom size: 1k * 16 bits. five external adc input ram size: 64 * 8 bits. one internal battery measurement internal ad reference voltage (vdd, 4v, 3v ,2v). ? four levels stack buffer. ? two 8-bit timer/counter ? i/o pin configuration tc0: auto-reload timer/counter/pwm0/buzzer output. bi-directional: p0, p4, p5. tc1: auto -reload timer/counter/pwm1/buzzer output. input only: p0.4 shared with reset pin. wakeup: p0 level change trigger. ? on chip watchdog timer and clock source is internal pull-up resisters: p0, p4, p5. low clock rc type (16khz @3v, 32khz @5v). external interrupt trigger edge: p0.0 controlled by pedge register. ? dual system clocks p0.1 is falling edge trigger only. external high clock: rc type up to 10 mhz. external high clock: crystal type up to 16 mhz. ? 3-level lvd. internal high clock: 16mhz rc type. reset system and power monitor. internal low clock: rc type 16khz(3v), 32khz(5v). ? five interrupt sources ? operating modes three internal interrupts: tc0, tc1, adc. normal mode: both high and low clock active. two external interrupts: int0, in t1. slow mode: low clock only. sleep mode: both high and low clock stop. ? powerful instructions green mode: periodical wakeup by tc0 timer one clocks per instruction cycle (1t) most of instructions are one cycle only. ? package (chip form support) all rom area jmp instruction. p-dip 14 pins all rom area call address instruction. sop 14 pins all rom area lookup table function (movc). ssop 16 pins
SN8P2711 8-bit micro-controller sonix technology co., ltd page 8 version 1.4 1.2 system block diagram interrupt control external high osc. acc internal low rc internal high rc timing generator ram system registers lvd (low voltage detector) watchdog timer pwm 1 buzzer 1 timer & counter p0 p5 p4 12-bit adc pwm 0 buzzer 0 alu pc flags ir otp rom pwm0 pwm1 buzzer0 buzzer1 ain0~ain4 internal reference internal adc channel for battery detect
SN8P2711 8-bit micro-controller sonix technology co., ltd page 9 version 1.4 1.3 pin assignment SN8P2711p (p-dip 14 pins) SN8P2711s (sop 14 pins) vdd 1 u 14 vss p0.3/xin 2 13 p4.4/ain4 p0.2/xout 3 12 p4.3/ain3 p0.4/rst/vpp 4 11 p4.2/ain2 p5.3/bz1/pwm1 5 10 p4.1/ain1 p5.4/bz0/pwm0 6 9 p4.0/ain0/vrefh p0.1/int1 7 8 p0.0/int0 SN8P2711p SN8P2711s SN8P2711x (ssop 16 pins) vdd 1 u 16 vss p0.3/xin 2 15 p4.4/ain4 p0.2/xout 3 14 p4.3/ain3 p0.4/rst/vpp 4 13 p4.2/ain2 p5.3/bz1/pwm1 5 12 p4.1/ain1 p5.4/bz0/pwm0 6 11 p4.0/ain0/vrefh p0.1/int1 7 10 p0.0/int0 nc 8 9 nc SN8P2711x
SN8P2711 8-bit micro-controller sonix technology co., ltd page 10 version 1.4 1.4 pin descriptions pin name type description vdd, vss p power supply input pins for digital circuit. p0.4/rst/vpp i, p p0.4: input only pin (schmitt trigger) if disable external reset function. p0.4 without build-in pull-up resister. p0.4 is input only pin without pull-up resistor under p0.4 mode. add the 100 ohm external resistor on p0.4, when it is set to be input pin. built-in wakeup function. rst: system reset input pin. schmitt tri gger structure, low active, normal stay to ?high?. vpp: otp programming pin. p0.3/xin i/o port 0.3 bi-direction pin. schmitt trigger structure as input mode. built-in pull-up resisters. built-in wakeup function. oscillator input pin while external oscillator enable (crystal and rc). p0.2/xout i/o port 0.2 bi-direction pin. schmitt trigger structure as input mode. built-in pull-up resisters. built-in wakeup function. xout: oscillator output pin while external crystal enable. p0.0/int0 i/o port 0.0 bi-direction pin. schmitt trigger structure as input mode. built-in pull-up resisters. built-in wakeup function. int0 trigger pin (schmitt trigger). tc0 event counter clock input pin. p0.1/int1 i/o port 0.1 bi-direction pin. schmitt trigger structure as input mode. built-in pull-up resisters. built-in wakeup function. int1 trigger pin (schmitt trigger). tc1 event counter clock input pin. p4.0/ain0/vrefh i/o port 4.0 bi-direction pin. no schmitt trigger structure. built-in pull-up resisters. ain0: adc channel-0 input. vrefh: adc external high reference voltage input. p4.[4:1]/ain[4:1] i/o port 4 [4:1] bi-direction pins. no schmitt trigger structure. built-in pull-up resisters. ain[4:1]: adc channel-1~4 input. p5.3/bz1/pwm1 i/o port 5.3 bi-direction pin. schmitt trigger structure as input mode. built-in pull-up resisters. tc1 2 signal output pin for buzzer or pwm1 output pin. p5.4/bz0/pwm0 i/o port 5.4 bi-direction pin. schmitt trigger structure as input mode. built-in pull-up resisters. tc0 2 signal output pin for buzzer or pwm0 output pin.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 11 version 1.4 1.5 pin circuit diagrams port 0.2, p0.3 structure: oscillator code option int. osc. pull-up pin output latch pnm, pnur input bus pnm output bus port 0.4 structure: pin ext. reset code option int. bus int. rst port 0, 5 structure: pull-up pin output latch pnm, pnur input bus pnm output bus
SN8P2711 8-bit micro-controller sonix technology co., ltd page 12 version 1.4 port 4.0 structure: int. verfh pin evhenb gchs int. adc p4con pull-up output latch pnm, pnur input bus pnm output bus port 4 structure: gchs int. adc p4con pull-up output latch pnm, pnur input bus pnm output bus pin
SN8P2711 8-bit micro-controller sonix technology co., ltd page 13 version 1.4 2 2 2 central processor unit (cpu) 2.1 memory map 2.1.1 program memory (rom) ) 1k words rom rom 0000h reset vector user reset vector jump to user start address 0001h . . 0007h general purpose area 0008h interrupt vector user interrupt vector 0009h user program . . 000fh 0010h 0011h . . . . . 03fch general purpose area end of user program 03fdh 03feh 03ffh reserved
SN8P2711 8-bit micro-controller sonix technology co., ltd page 14 version 1.4 2.1.1.1 reset vector (0000h) a one-word vector address area is used to execute system reset. ) power on reset (nt0=1, npd=0). ) watchdog reset (nt0=0, npd=0). ) external reset (nt0=1, npd=1). after power on reset, external reset or watchdog timer over flow reset, then the chip will restart the program from address 0000h an d all system registers will be set as default values . it is easy to know rese t status from nt0, npd flags of pflag register. the following example shows the way to define the reset vector in the program memory. ? example: defining reset vector org 0 ; 0000h jmp start ; jump to user program address. ? org 10h start: ; 0010h, the head of user program. ? ; user program ? endp ; end of program
SN8P2711 8-bit micro-controller sonix technology co., ltd page 15 version 1.4 2.1.1.2 interrupt vector (0008h) a 1-word vector address area is used to execute interr upt request. if any interrupt se rvice executes, the program counter (pc) value is stored in stack buffer and jump to 0008h of program memory to execute the vectored interrupt. users have to define the interr upt vector. the following example shows the wa y to define the interrupt vector in the program memory. ? note: ?push?, ?pop? instructions save and load ac c/pflag without (nt0, npd). push/pop buffer is a unique buffer and only one level. ? example: defining interrupt vector. the in terrupt service routine is following org 8. .code org 0 ; 0000h jmp start ; jump to user program address. ? org 8 ; interrupt vector. push ; save acc and pflag register to buffers. ? ? pop ; load acc and pflag register from buffers. reti ; end of interrupt service routine ? start: ; the head of user program. ? ; user program ? jmp start ; end of user program ? endp ; end of program
SN8P2711 8-bit micro-controller sonix technology co., ltd page 16 version 1.4 ? example: defining interrupt vector. the interru pt service routine is following user program. .code org 0 ; 0000h jmp start ; jump to user program address. ? org 8 ; interrupt vector. jmp my_irq ; 0008h, jump to interrupt service routine address. org 10h start: ; 0010h, the head of user program. ? ; user program. ? ? jmp start ; end of user program. ? my_irq: ;the head of interrupt service routine. push ; save acc and pflag register to buffers. ? ? pop ; load acc and pflag register from buffers. reti ; end of interrupt service routine. ? endp ; end of program. ? note: it is easy to understand the rules of sonix program from demo programs given above. these points are as following: 1. the address 0000h is a ?jmp? instruction to make the program starts from the beginning. 2. the address 0008h is interrupt vector. 3. user?s program is a loop routine for main purpose application.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 17 version 1.4 2.1.1.3 look-up table description in the rom?s data lookup function, y register is pointed to middle byte address (bit 8~bit 15) and z register is pointed to low byte address (bit 0~bit 7) of rom. after movc instruction executed, t he low-byte data will be stored in acc and high-byte data stored in r register. ? example: to look up the rom data located ?table1?. b0mov y, #table1$m ; to set lookup table1?s middle address b0mov z, #table1$l ; to set lookup table1?s low address. movc ; to lookup data, r = 00h, acc = 35h ; increment the index address for next address. incms z ; z+1 jmp @f ; z is not overflow. incms y ; z overflow (ffh ? 00), ? y=y+1 nop ; ; @@: movc ; to lookup data, r = 51h, acc = 05h. ? ; table1: dw 0035h ; to define a word (16 bits) data. dw 5105h dw 2012h ? ? note: the y register will not increase automatically wh en z register crosses boundary from 0xff to 0x00. therefore, user must take care such situation to avoid look-up table errors. if z register overflows, y register must be added one. the following inc_yz macro shows a simple method to process y and z registers automatically. ? example: inc_yz macro. inc_yz macro incms z ; z+1 jmp @f ; not overflow incms y ; y+1 nop ; not overflow @@: endm
SN8P2711 8-bit micro-controller sonix technology co., ltd page 18 version 1.4 ? example: modify above exam ple by ?inc_yz? macro. b0mov y, #table1$m ; to set lookup table1?s middle address b0mov z, #table1$l ; to set lookup table1?s low address. movc ; to lookup data, r = 00h, acc = 35h inc_yz ; increment the index address for next address. ; @@: movc ; to lookup data, r = 51h, acc = 05h. ? ; table1: dw 0035h ; to define a word (16 bits) data. dw 5105h dw 2012h ? the other example of look-up table is to add y or z index r egister by accumulator. please be careful if ?carry? happen. ? example: increase y and z register by b0add/add instruction. b0mov y, #table1$m ; to set lookup table?s middle address. b0mov z, #table1$l ; to set lookup table?s low address. b0mov a, buf ; z = z + buf. b0add z, a b0bts1 fc ; check the carry flag. jmp getdata ; fc = 0 incms y ; fc = 1. y+1. nop getdata: ; movc ; to lookup data. if buf = 0, data is 0x0035 ; if buf = 1, data is 0x5105 ; if buf = 2, data is 0x2012 ? table1: dw 0035h ; to define a word (16 bits) data. dw 5105h dw 2012h ?
SN8P2711 8-bit micro-controller sonix technology co., ltd page 19 version 1.4 2.1.1.4 jump table description the jump table operation is one of multi-address jumpin g function. add low-byte program counter (pcl) and acc value to get one new pcl. if pcl is overflow after pcl+ acc, pch adds one automatically. the new program counter (pc) points to a series jump instructions as a listing t able. it is easy to make a multi-jump program depends on the value of the accumulator (a). ? note: pch only support pc up counting result and doesn?t support pc down counting. when pcl is carry after pcl+acc, pch adds one automatically. if pcl borrow after pcl?acc, pch keeps value and not change. ? example: jump table. org 0x0100 ; the jump table is from the head of the rom boundary b0add pcl, a ; pcl = pcl + acc, pch + 1 when pcl overflow occurs . jmp a0point ; acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point sonix provides a macro for safe jump table function. th is macro will check the rom boundary and move the jump table to the right position automatically. the side e ffect of this macro maybe wastes some rom size. ? example: if ?jump table? crosses over rom boundary will cause errors. @jmp_a macro val if (($+1) !& 0xff00) !!= (($+(val)) !& 0xff00) jmp ($ | 0xff) org ($ | 0xff) endif add pcl, a endm ? note: ?val? is the number of the jump table listing number.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 20 version 1.4 ? example: ?@jmp_a? application in sonix macro file called ?macro3.h?. b0mov a, buf0 ; ?buf0? is from 0 to 4. @jmp_a 5 ; the number of the jump table listing is five. jmp a0point ; acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point jmp a4point ; acc = 4, jump to a4point if the jump table position is across a rom boundary (0x00ff~ 0x0100), the ?@jmp_a? macro will adjust the jump table routine begin from next ram boundary (0x0100). ? example: ?@jmp_a? operation. ; before compiling program. rom address b0mov a, buf0 ; ?buf0? is from 0 to 4. @jmp_a 5 ; the number of the jump table listing is five. 0x00fd jmp a0point ; acc = 0, jump to a0point 0x00fe jmp a1point ; acc = 1, jump to a1point 0x00ff jmp a2point ; acc = 2, jump to a2point 0x0100 jmp a3point ; acc = 3, jump to a3point 0x0101 jmp a4point ; acc = 4, jump to a4point ; after compiling program. rom address b0mov a, buf0 ; ?buf0? is from 0 to 4. @jmp_a 5 ; the number of the jump table listing is five. 0x0100 jmp a0point ; acc = 0, jump to a0point 0x0101 jmp a1point ; acc = 1, jump to a1point 0x0102 jmp a2point ; acc = 2, jump to a2point 0x0103 jmp a3point ; acc = 3, jump to a3point 0x0104 jmp a4point ; acc = 4, jump to a4point
SN8P2711 8-bit micro-controller sonix technology co., ltd page 21 version 1.4 2.1.1.5 checksum calculation the last rom address are reserved area. user should avoi d these addresses (last address) when calculate the checksum value. ? example: the demo program shows how to calculated checksum from 00h to the end of user?s code. mov a,#end_user_code$l b0mov end_addr1, a ; save low end address to end_addr1 mov a,#end_user_code$m b0mov end_addr2, a ; save middle end address to end_addr2 clr y ; set y to 00h clr z ; set z to 00h @@: movc b0bset fc ; clear c flag add data1, a ; add a to data1 mov a, r adc data2, a ; add r to data2 jmp end_check ; check if the yz address = the end of code aaa: incms z ; z=z+1 jmp @b ; if z != 00h calculate to next address jmp y_add_1 ; if z = 00h increase y end_check: mov a, end_addr1 cmprs a, z ; check if z = low end address jmp aaa ; if not jump to checksum calculate mov a, end_addr2 cmprs a, y ; if yes, check if y = middle end address jmp aaa ; if not jump to checksum calculate jmp checksum_end ; if yes checksum calculated is done. y_add_1: incms y ; increase y nop jmp @b ; jump to checksum calculate checksum_end: ? ? end_user_code: ; label of program end
SN8P2711 8-bit micro-controller sonix technology co., ltd page 22 version 1.4 2.1.2 code option table code option content function description ihrc_16m high speed internal 16mhz rc. xin/xout become to p0.3/p0.2 bi-direction i/o pins. rc low cost rc for external high clock oscillator and xout becomes to p0.2 bit-direction i/o pin. 12m x?tal high speed crystal /resonator (e.g. 12mhz) for external high clock oscillator. high_clk 4m x?tal standard crystal /resonator (e.g. 4m) for external high clock oscillator. always_on watchdog timer is always on enable even in power down and green mode. enable enable watchdog timer. watchdog timer stops in power down mode and green mode. watch_dog disable disable watchdog function. fhosc/1 instruction cycle is oscillator clock. notice: in fosc/1, noise filter must be disabled. fhosc/2 instruction cycle is 2 oscillator clocks. notice: in fosc/2, noise filter must be disabled. fhosc/4 instruction cycle is 4 oscillator clocks. fhosc/8 instruction cycle is 8 oscillator clocks. fcpu fhosc/16 instruction cycle is 16 oscillator clocks. reset enable external reset pin. reset_pin p04 enable p0.4 input only without pull-up resister. enable enable rom code security function. security disable disable rom code security function. enable enable noise filter and the fcpu is fosc/4~fosc/16. noise_filter disable disable noise filter and the fcpu is fosc/1~fosc/16. lvd_l lvd will reset chip if vdd is below 2.0v lvd_m lvd will reset chip if vdd is below 2.0v enable lvd24 bit of pflag register for 2.4v low voltage indicator. lvd lvd_h lvd will reset chip if vdd is below 2.4v enable lvd36 bit of pflag register for 3.6v low voltage indicator. ? note: 1. in high noisy environment, enable ?noise filter? and set watch_dog as ?always_on? is strongly recommended. enable ?noise_filter? will limit the fcpu = fosc/4 ~ fosc/128. 2. if users define watchdog as ?always_on?, assembler will enable ?watch_dog? automatically. 3. fcpu code option is only available for high clock. fcpu of slow mode is fosc/4 (the fosc is internal low clock).
SN8P2711 8-bit micro-controller sonix technology co., ltd page 23 version 1.4 2.1.3 data memory (ram) ) 64 x 8-bit ram address ram location 000h ? ? ? ? ? 03fh general purpose area 080h ? 080h~0ffh of bank 0 store system registers (128 bytes). ? ? ? ? system register bank 0 0ffh end of bank 0 area
SN8P2711 8-bit micro-controller sonix technology co., ltd page 24 version 1.4 2.1.4 system register 2.1.4.1 system register table 0 1 2 3 4 5 6 7 8 9 a b c d e f 8 - - r z y - pflag - - - - - - - - - 9 - - - - - - - - - - - - - - - - a - - - - - - - - - - - - - - p4con vrefh b - adm adb adr - - - - p0m - - - - - - pedge c - - - - p4m p5m - - intrq inten oscm - wdtr tc0r pcl pch d p0 - - - p4 p5 - - t0m - tc0m tc0c tc1m tc1c tc1r stkp e p0ur - - - p4ur p5ur - @yz - - - - - - - - f - - - - - - - - stk3l stk3h stk2l stk2h stk1l stk1h stk0l stk0h 2.1.4.2 system register description r = working register and rom look-up data buffer. y, z = working, @yz and rom addressing register. pflag = rom page and special flag register . p4con = p4 configuration register. vrefh = adc high reference voltage register. adm = adc?s mode register. adb = adc data buffer. adr = adc resolution selection register. pnm = port n input/output mode register. pedge = p0.0 edge direction register. intrq = interrupt request register. inten = interrupt enable register. oscm = oscillator mode register. wd tr = watchdog timer clear register. tc0r = tc0 auto-reload data buffer. pch, pcl = program counter. pn = port n data buffer. t0m = tc0/tc1 speed-up and tc0 wake-up function register. tc0m = tc0 mode register. tc0c = tc0 counting register. tc1m = tc1 mode register. tc1c = tc1 counting register. tc1r = tc1 auto-reload data buffer. stkp = stack pointer buffer. pnur = port n pull-up resister control register. @yz = ram yz indirect addressing index pointer. stk0~stk3 = stack 0 ~ stack 3 buffer.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 25 version 1.4 2.1.4.3 bit definition of system register address bit7 bit6 bit5 bit4 bi t3 bit2 bit1 bit0 r/w remarks 082h rbit7 rbit6 rbit5 rbit4 rbit3 rbit2 rbit1 rbit0 r/w r 083h zbit7 zbit6 zbit5 zbit4 zbit3 zbit2 zbit1 zbit0 r/w z 084h ybit7 ybit6 ybit5 ybit4 ybit3 ybit2 ybit1 ybit0 r/w y 086h nt0 npd lvd36 lvd24 c dc z r/w pflag 0aeh p4con4 p4con3 p4co n2 p4con1 p4con0 r/w p4con 0afh evhenb vhs1 vhs2 r/w vrefh 0b1h adenb ads eoc gchs chs2 chs1 chs0 r/w adm 0b2h adb11 adb10 adb9 adb8 adb7 adb6 adb5 adb4 r adb 0b3h adcks1 adcks0 adb3 adb2 adb1 adb0 r/w adr 0b8h p03m p02m p01m p00m r/w p0m 0bfh p00g1 p00g0 r/w pedge 0c4h p44m p43m p42m p41m p40m r/w p4m 0c5h p54m p53m r/w p5m 0c8h adcirq tc1irq tc0irq p01irq p00irq r/w intrq 0c9h adcien tc1ien tc0ien p01ien p00ien r/w inten 0cah cpum1 cpum0 clkmd stphx r/w oscm 0cch wdtr7 wdtr6 wdtr5 wdtr4 wdtr3 wdtr2 wdtr1 wdtr0 w wdtr 0cdh tc0r7 tc0r6 tc0r5 tc0r4 tc0r3 tc0r2 tc0r1 tc0r0 w tc0r 0ceh pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 r/w pcl 0cfh pc9 pc8 r/w pch 0d0h p04 p03 p02 p01 p00 r/w p0 0d4h p44 p43 p42 p41 p40 r/w p4 0d5h p54 p53 r/w p5 0d8h tc1x8 tc0x8 tc0gn r/w t0m 0dah tc0enb tc0rate2 tc0rate1 tc0rate0 tc0cks aload0 tc0out pwm0out r/w tc0m 0dbh tc0c7 tc0c6 tc0c5 tc0c4 tc0c3 tc0c2 tc0c1 tc0c0 r/w tc0c 0dch tc1enb tc1rate2 tc1rate1 tc1rate0 tc1cks aload1 tc1out pwm1out r/w tc1m 0ddh tc1c7 tc1c6 tc1c5 tc1c4 tc1c3 tc1c2 tc1c1 tc1c0 r/w tc1c 0deh tc1r7 tc1r6 tc1r5 tc1r4 tc1r3 tc1r2 tc1r1 tc1r0 w tc1r 0dfh gie stkpb2 stkpb1 stkpb0 r/w stkp 0e0h p03r p02r p01r p00r w p0ur 0e4h p44r p43r p42r p41r p40r w p4ur 0e5h p54r p53r w p5ur 0e7h @yz7 @yz6 @yz5 @yz4 @yz3 @yz2 @yz1 @yz0 r/w @yz 0f8h s3pc7 s3pc6 s3pc5 s3pc4 s3pc3 s3pc2 s3pc1 s3pc0 r/w stk3l 0f9h s3pc9 s3pc8 r/w stk3h 0fah s2pc7 s2pc6 s2pc5 s2pc4 s2 pc3 s2pc2 s2pc1 s2pc0 r/w stk2l 0fbh s2pc9 s2pc8 r/w stk2h 0fch s1pc7 s1pc6 s1pc5 s1pc4 s1pc3 s1pc2 s1pc1 s1pc0 r/w stk1l 0fdh s1pc9 s1pc8 r/w stk1h 0feh s0pc7 s0pc6 s0pc5 s0pc4 s0 pc3 s0pc2 s0pc1 s0pc0 r/w stk0l 0ffh s0pc9 s0pc8 r/w stk0h ? note: 1. to avoid system error, make sure to put all the ?0? and ?1? as it indicates in the above table . 2. all of register names had been declared in sn8asm assembler. 3. one-bit name had been declared in sn8asm assembler with ?f? prefix code. 4. ?b0bset?, ?b0bclr?, ?bset?, ?bclr? instruct ions are only available to the ?r/w? registers.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 26 version 1.4 2.1.4.4 accumulator the acc is an 8-bit data register responsible for trans ferring or manipulating data between alu and data memory. if the result of operating is zero (z) or there is carry (c or dc) occurrence, then these flags will be set to pflag register. acc is not in data memory (ram), so acc can?t be acce ss by ?b0mov? instruction dur ing the instant addressing mode. ? example: read and write acc value. ; read acc data and store in buf data memory. mov buf, a ; write a immediate data into acc. mov a, #0fh ; write acc data from buf data memory. mov a, buf ; or b0mov a, buf the system doesn?t store acc and pfla g value when interrupt executed. a cc and pflag data must be saved to other data memories. ?push?, ?pop? save and load acc, pflag data into buffers. ? example: protect acc and working registers. int_service: push ; save acc and pflag to buffers. ? . ? pop ; load acc and pflag from buffers. reti ; exit interrupt service vector
SN8P2711 8-bit micro-controller sonix technology co., ltd page 27 version 1.4 2.1.4.5 program flag the pflag register contains the arithm etic status of alu operat ion, system reset status and lvd detecting status. nt0, npd bits indicate system reset status including po wer on reset, lvd reset, reset by external pin active and watchdog reset. c, dc, z bits indicate the result status of alu operation. lvd24, lvd36 bits indicate lvd detecting power voltage status. 086h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag nt0 npd lvd36 lvd24 - c dc z read/write r/w r/w r r - r/w r/w r/w after reset - - 0 0 - 0 0 0 bit [7:6] nt0, npd: reset status flag. nt0 npd reset status 0 0 watch-dog time out 0 1 reserved 1 0 reset by lvd 1 1 reset by external reset pin bit 5 lvd36: lvd 3.6v operating flag and only s upport lvd code option is lvd_h. 0 = inactive (vdd > 3.6v). 1 = active (vdd <= 3.6v). bit 4 lvd24: lvd 2.4v operating flag and only s upport lvd code option is lvd_m. 0 = inactive (vdd > 2.4v). 1 = active (vdd <= 2.4v). bit 2 c: carry flag 1 = addition with carry, subtraction without borrowing, ro tation with shifting out logic ?1?, comparison result 0. 0 = addition without carry, s ubtraction with borrowing signal, rotation wi th shifting out logic ?0?, comparison result < 0. bit 1 dc: decimal carry flag 1 = addition with carry from low nibble, s ubtraction without borrow from high nibble. 0 = addition without carry from low nibble, subtraction with borrow from high nibble. bit 0 z: zero flag 1 = the result of an arithmetic/logic/branch operation is zero. 0 = the result of an arithmetic/logic/branch operation is not zero. ? note: refer to instruction set table for detailed information of c, dc and z flags.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 28 version 1.4 2.1.4.6 program counter the program counter (pc) is a 10-bit binary counter sepa rated into the high-byte 2 and the low-byte 8 bits. this counter is responsible for pointing a location in order to fe tch an instruction for kernel circuit. normally, the program counter is automatically incremented with eac h instruction during program execution. besides, it can be replaced with specific address by execut ing call or jmp instruction. when jmp or call instruction is executed, the desti nation address will be inserted to bit 0 ~ bit 9. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc - - - - - - pc9 pc8 pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 after reset - - - - - - 0 0 0 0 0 0 0 0 0 0 pch pcl ) one address skipping there are nine instructions (cmprs, incs, incms, de cs, decms, bts0, bts1, b0bts0, b0bts1) with one address skipping function. if the result of these instructions is true, the pc will add 2 steps to skip next instruction. if the condition of bit test instruction is true, the pc will add 2 steps to skip next instruction. b0bts1 fc ; to skip, if carry_flag = 1 jmp c0step ; else jump to c0step. ? ? c0step: nop b0mov a, buf0 ; move buf0 value to acc. b0bts0 fz ; to skip, if zero flag = 0. jmp c1step ; else jump to c1step. ? ? c1step: nop if the acc is equal to the immediat e data or memory, the pc will add 2 steps to skip next instruction. cmprs a, #12h ; to skip, if acc = 12h. jmp c0step ; else jump to c0step. ? ? c0step: nop
SN8P2711 8-bit micro-controller sonix technology co., ltd page 29 version 1.4 if the destination increased by 1, wh ich results overflow of 0xff to 0x00, the pc will add 2 steps to skip next instruction. incs instruction: incs buf0 jmp c0step ; jump to c0step if acc is not zero. ? ? c0step: nop incms instruction: incms buf0 jmp c0step ; jump to c0step if buf0 is not zero. ? ? c0step: nop if the destination decreased by 1, which results underflo w of 0x00 to 0xff, the pc will add 2 steps to skip next instruction. decs instruction: decs buf0 jmp c0step ; jump to c0step if acc is not zero. ? ? c0step: nop decms instruction: decms buf0 jmp c0step ; jump to c0step if buf0 is not zero. ? ? c0step: nop
SN8P2711 8-bit micro-controller sonix technology co., ltd page 30 version 1.4 ) multi-address jumping users can jump around the mult i-address by either jmp inst ruction or add m, a instruction (m = pcl) to activate multi-address jumping function. program counter supports ?add m,a? , ?adc m,a? and ?b0add m,a? instructions for carry to pch when pcl overflow automatically. for jump t able or others applications, users can calculate pc value by the three instructions and don?t care pcl overflow problem. ? note: pch only support pc up counting result and doesn?t support pc down counting. when pcl is carry after pcl+acc, pch adds one automatically. if pcl borrow after pcl?acc, pch keeps value and not change. ? example: if pc = 0323h (pch = 03h, pcl = 23h) ; pc = 0323h mov a, #28h b0mov pcl, a ; jump to address 0328h ? ; pc = 0328h mov a, #00h b0mov pcl, a ; jump to address 0300h ? ? example: if pc = 0323h (pch = 03h, pcl = 23h) ; pc = 0323h b0add pcl, a ; pcl = pcl + ac c, the pch cannot be changed. jmp a0point ; if acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point ? ?
SN8P2711 8-bit micro-controller sonix technology co., ltd page 31 version 1.4 2.1.4.7 y, z registers the y and z registers are the 8-bit buffers. there ar e three major functions of these registers. z can be used as general working registers z can be used as ram data pointers with @yz register z can be used as rom data pointer with the movc instruction for look-up table 084h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 y ybit7 ybit6 ybit5 ybit4 ybit3 ybit2 ybit1 ybit0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset - - - - - - - - 083h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 z zbit7 zbit6 zbit5 zbit4 zbit3 zbit2 zbit1 zbit0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset - - - - - - - - ? example: uses y, z register as the data pointer to access data in the ram address 025h of bank0. b0mov y, #00h ; to set ram bank 0 for y register b0mov z, #25h ; to set location 25h for z register b0mov a, @yz ; to read a data into acc ? example: uses the y, z register as data pointer to clear the ram data. b0mov y, #0 ; y = 0, bank 0 b0mov z, #07fh ; z = 7fh, the last address of the data memory area clr_yz_buf: clr @yz ; clear @yz to be zero decms z ; z ? 1, if z= 0, finish the routine jmp clr_yz_buf ; not zero clr @yz end_clr: ; end of clear general purpose data memory area of bank 0 ?
SN8P2711 8-bit micro-controller sonix technology co., ltd page 32 version 1.4 2.1.4.8 r registers r register is an 8-bit buffer. there ar e two major functions of the register. z can be used as working register z for store high-byte data of look-up table (movc instruction executed, the high- byte data of specified rom address will be stored in r register and the low-byte data will be stored in acc). 082h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r rbit7 rbit6 rbit5 rbit4 rbit3 rbit2 rbit1 rbit0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset - - - - - - - - ? note: please refer to the ?look-up table description? about r regi ster look-up table application.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 33 version 1.4 2.2 addressing mode 2.2.1 immediate addressing mode the immediate addressing mode uses an immediate data to set up the location in acc or specific ram. ? example: move the immediate data 12h to acc. mov a, #12h ; to set an immediate data 12h into acc. ? example: move the immediate data 12h to r register. b0mov r, #12h ; to set an immediate data 12h into r register. ? note: in immediate addressing mode application, th e specific ram must be 0x80~0x87 working register. 2.2.2 directly addressing mode the directly addressing mode moves the cont ent of ram location in or out of acc. ? example: move 0x12 ram location data into acc. b0mov a, 12h ; to get a content of ram location 0x12 of bank 0 and save in acc. ? example: move acc data into 0x12 ram location. b0mov 12h, a ; to get a content of acc and save in ram location 12h of bank 0. 2.2.3 indirectly addressing mode the indirectly addressing mode is to access the memory by the data pointer registers (y/z). ? example: indirectly addressing mode with @yz register. b0mov y, #0 ; to clear y register to access ram bank 0. b0mov z, #12h ; to set an immediate data 12h into z register. b0mov a, @yz ; use data pointer @yz reads a data from ram location ; 012h into acc.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 34 version 1.4 2.3 stack operation 2.3.1 overview the stack buffer has 4-level. these buffers are designed to push and pop up program counter?s (pc) data when interrupt service routine and ?call? inst ruction are executed. the stkp register is a pointer designed to point active level in order to push or pop up data from stack buffer. the stknh and stknl are the stack buffers to store program counter (pc) data. ret / reti call / interrupt stkp = 3 stkp = 2 stkp = 1 stkp = 0 stack level stk3h stk2h stk1h stk0h stack buffer high byte pch stkp stk3l stk2l stk1l stk0l stack buffer low byte pcl stkp stkp - 1 stkp + 1
SN8P2711 8-bit micro-controller sonix technology co., ltd page 35 version 1.4 2.3.2 stack registers the stack pointer (stkp) is a 3-bit register to store t he address used to access the st ack buffer, 10-bit data memory (stknh and stknl) set aside for temp orary storage of stack addresses. the two stack operations are writing to the top of the stac k (push) and reading from the top of stack (pop). push operation decrements the stkp and the pop operation increments each time. that makes the stkp always point to the top address of stack buffer and wr ite the last program counter val ue (pc) into the stack buffer. the program counter (pc) value is stored in the stack bu ffer before a call instruction ex ecuted or during interrupt service routine. stack operation is a lifo type (last in and first out). the stack pointer (stkp) and stack buffer (stknh and stknl) are located in t he system register area bank 0. 0dfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie - - - - stkpb2 stkpb1 stkpb0 read/write r/w - - - - r/w r/w r/w after reset 0 - - - - 1 1 1 bit[2:0] stkpbn: stack pointer (n = 0 ~ 2) bit 7 gie: global interrupt control bit. 0 = disable. 1 = enable. please refer to the interrupt chapter. ? example: stack pointer (stkp) reset, we strongl y recommended to clear the stack pointers in the beginning of the program. mov a, #00000111b b0mov stkp, a 0f0h~0ffh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stknh - - - - - - snpc9 snpc8 read/write - - - - - - r/w r/w after reset - - - - - - 0 0 0f0h~0ffh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stknl snpc7 snpc6 snpc5 snpc4 snpc3 snpc2 snpc1 snpc0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 stkn = stknh , stknl (n = 3 ~ 0)
SN8P2711 8-bit micro-controller sonix technology co., ltd page 36 version 1.4 2.3.3 stack operation example the two kinds of stack-save operations re fer to the stack pointer (stkp) and writ e the content of program counter (pc) to the stack buffer are call instructi on and interrupt service. under each conditi on, the stkp decreases and points to the next available stack location. the stack buffer stor es the program counter about the op-code address. the stack-save operation is as the following table. stkp register stack buffer stack level stkpb2 stkpb1 stkpb0 high byte low byte description 0 1 1 1 free free - 1 1 1 0 stk0h stk0l - 2 1 0 1 stk1h stk1l - 3 1 0 0 stk2h stk2l - 4 0 1 1 stk3h stk3l - > 4 0 1 0 - - stack over, error there are stack-restore operations correspond to each push operation to restore the prog ram counter (pc). the reti instruction uses for interrupt service routine. the ret inst ruction is for call instruction. when a pop operation occurs, the stkp is incremented and points to the next free stack loca tion. the stack buffer restores the last program counter (pc) to the program counter registers. the stac k-restore operation is as the following table. stkp register stack buffer stack level stkpb2 stkpb1 stkpb0 high byte low byte description 4 0 1 1 stk3h stk3l - 3 1 0 0 stk2h stk2l - 2 1 0 1 stk1h stk1l - 1 1 1 0 stk0h stk0l - 0 1 1 1 free free -
SN8P2711 8-bit micro-controller sonix technology co., ltd page 37 version 1.4 3 3 3 reset 3.1 overview the system would be reset in three conditions as following. z power on reset z watchdog reset z brown out reset z external reset (only supports external reset pin enable situation) when any reset condition occurs, all syst em registers keep initial status, progra m stops and program counter is cleared. after reset status released, the system boots up and progra m starts to execute from org 0. the nt0, npd flags indicate system reset status. the system can depend on nt0, npd status and go to diffe rent paths by program. 086h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag nt0 npd lvd36 lvd24 - c dc z read/write r/w r/w r r - r/w r/w r/w after reset - - 0 0 - 0 0 0 bit [7:6] nt0, npd: reset status flag. nt0 npd condition description 0 0 watchdog reset watchdog timer overflow. 0 1 reserved - 1 0 power on reset and lvd reset. power voltage is lower than lvd detecting level. 1 1 external reset external reset pin detect low level status. finishing any reset sequence needs some time. the system provides complete procedures to make the power on reset successful. for different oscillat or types, the reset time is different. that causes the vdd rise rate and start-up time of different oscillator is not fixed. rc ty pe oscillator?s start-up time is very shor t, but the crystal type is longer. under clie nt terminal application, users have to take care the power on reset time for the master terminal requirement. the reset timing diagram is as following. vdd vss vdd vss watchdog normal run watchdog stop system normal run system stop lvd detect level external reset low detect external reset high detect watchdog overflow watchdog reset delay time external reset delay time power on delay time power external reset watchdog reset system status
SN8P2711 8-bit micro-controller sonix technology co., ltd page 38 version 1.4 3.2 power on reset the power on reset depend no lvd operation for most power- up situations. the power supplying to system is a rising curve and needs some time to achieve the normal voltage. power on reset sequence is as following. z power-up: system detects the power voltage up and waits for power stable. z external reset (only external reset pin enable): system checks external reset pin status. if external reset pin is not high level, the system keeps reset stat us and waits external reset pin released. z system initialization: all system registers is set as initia l conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and program executes from org 0. 3.3 watchdog reset watchdog reset is a system protection. in normal condition, system works well and clears watchdog timer by program. under error condition, system is in unknown situation and watchdog can?t be clear by program before watchdog timer overflow. watchdog timer overflow occurs and the system is reset. after watchdog reset, the system restarts and returns normal mode. watchdog reset sequence is as following. z watchdog timer status: system checks watchdog timer overflow stat us. if watchdog timer ov erflow occurs, the system is reset. z system initialization: all system registers is set as initia l conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and program executes from org 0. watchdog timer application note is as following. z before clearing watchdog timer, check i/o status and check ram contents c an improve system error. z don?t clear watchdog timer in interrupt vector and interrupt service routine. that can improve main routine fail. z clearing watchdog timer program is only at one part of the program. this way is the best structure to enhance the watchdog timer function. ? note: please refer to the ?watchdog timer? about watchdog timer detail information.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 39 version 1.4 3.4 brown out reset 3.4.1 brown out description the brown out reset is a power dropping condition. the powe r drops from normal voltage to low voltage by external factors (e.g. eft interference or extern al loading changed). the brown out reset would make the system not work well or executing program error. vdd vss v1 v2 v3 system work well area system work error area brown out reset diagram the power dropping might through the voltage range that ?s the system dead-band. the dead-band means the power range can?t offer the system minimum operation power re quirement. the above diagram is a typical brown out reset diagram. there is a serious noise under the vdd, and vdd voltage drops very deep. there is a dotted line to separate the system working area. the above area is the system work well area. the below area is the system work error area called dead-band. v1 doesn?t touch the below area and not effe ct the system operation. but the v2 and v3 is under the below area and may induce the system error occurrence. let system under dead-band includes some conditions. dc application: the power source of dc application is usually using battery . when low battery condition and mcu drive any loading, the power drops and keeps in dead-band. under the situat ion, the power won?t drop dee per and not touch the system reset voltage. that makes the system under dead-band. ac application: in ac power application, the dc power is regulated from ac power source. this kind of power usually couples with ac noise that makes the dc power dirty. or the external loading is very heavy, e. g. driving motor. the loading operating induces noise and overlaps with the dc power. vdd drop s by the noise, and the system works under unstable power situation. the power on duration and power down duration are longer in ac application. the system power on sequence protects the power on successful, but the power do wn situation is like dc low battery condition. when turn off the ac power, the vdd drops slowly and through the dead-band for a while.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 40 version 1.4 3.4.2 the system operating voltage decsription to improve the brown out reset needs to know the system minimum operating voltage which is depend on the system executing rate and power level. differe nt system executing rates have differe nt system minimum operating voltage. the electrical characteristic section shows the system voltage to executing rate relationship. vdd (v) system rate (fcpu) system mini. operating voltage. system reset voltage. dead-band area normal operating area reset area normally the system operation voltage ar ea is higher than the system reset voltage to vdd, and the reset voltage is decided by lvd detect level. the system minimum operating voltage rises when the system executing rate upper even higher than system reset voltage. the dead-band definition is the system minimum operat ing voltage above the system reset voltage. 3.4.3 brown out reset improvement how to improve the brown reset condition? there are some methods to improve brown out reset as following. z lvd reset z watchdog reset z reduce the system executing rate z external reset circuit. (zener diode reset circuit, voltage bias reset circuit, external reset ic) ? note: 1. the ? zener diode reset circuit?, ?voltage bias reset circuit? and ?external reset ic? can completely improve the brown out reset, dc low battery and ac slow power down conditions. 2. for ac power application and enhance eft performance, the system clock is 4mhz/4 ( 1 mips ) and use external reset (? zener diode reset circui t?, ?voltage bias reset circuit?, ?external reset ic?). the structure can improve noise effective and get good eft characteristic.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 41 version 1.4 lvd reset: vdd vss system normal run system stop lvd detect voltage power on delay time power system status power is below lvd detect voltage and system reset. the lvd (low voltage detector) is built-in sonix 8-bit mcu to be brown out reset protection. when the vdd drops and is below lvd detect voltage, the lvd would be triggered, an d the system is reset. the lvd detect level is different by each mcu. the lvd voltage level is a point of volt age and not easy to cover all dead-band range. using lvd to improve brown out reset is depend on application requiremen t and environment. if the power variation is very deep, violent and trigger the lvd, the lvd ca n be the protection. if the power variation can touch the lvd detect level and make system work error, the lvd can? t be the protection and need to other reset methods. more detail lvd information is in the electrical characteristic section. the lvd is three levels design (2.0v/2.4v/3.6v) and contro lled by lvd code option. the 2.0v lvd is always enable for power on reset and brown out reset. the 2.4v lvd includes lvd reset function and flag function to indicate vdd status function. the 3.6v includes flag function to indicate vdd status. lvd flag function can be an easy low battery detector . lvd24, lvd36 flags indicate vdd voltage level. fo r low battery detect application, only checking lvd24, lvd36 status to be battery status. this is a cheap and easy solution. 086h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag nt0 npd lvd36 lvd24 - c dc z read/write r/w r/w r r - r/w r/w r/w after reset - - 0 0 - 0 0 0 bit 5 lvd36: lvd 3.6v operating flag and only s upport lvd code option is lvd_h. 0 = inactive (vdd > 3.6v). 1 = active (vdd <= 3.6v). bit 4 lvd24: lvd 2.4v operating flag and only s upport lvd code option is lvd_m. 0 = inactive (vdd > 2.4v). 1 = active (vdd <= 2.4v).
SN8P2711 8-bit micro-controller sonix technology co., ltd page 42 version 1.4 lvd code option lvd lvd_l lvd_m lvd_h 2.0v reset available available available 2.4v flag - available - 2.4v reset - - available 3.6v flag - - available lvd_l if vdd < 2.0v, system will be reset. disable lvd24 and lvd36 bit of pflag register lvd_m if vdd < 2.0v, system will be reset. enable lvd24 bit of pflag register. if vdd > 2.4v, lvd24 is ?0?. if vdd <= 2.4v, lvd24 flag is ?1? disable lvd36 bit of pflag register lvd2_h if vdd < 2.4v, system will be reset. enable lvd24 bit of pflag register. if vdd > 2.4v, lvd24 is ?0?. if vdd <= 2.4v, lvd24 flag is ?1? enable lvd36 bit of pflag register. if vdd > 3.6v, lvd36 is ?0?. if vdd <= 3.6v, lvd36 flag is ?1? ? note: 1. after any lvd reset, lvd 24, lvd36 flags are cleared. 2. the voltage level of lvd 2.4v or 3.6v is fo r design reference only. don?t use the lvd indicator as precision vdd measurement. watchdog reset: the watchdog timer is a protection to make sure the system executes well. normally the watchdog timer would be clear at one point of program. don?t clear the watchdog timer in several addresses. the system executes normally and the watchdog won?t reset system. when the system is under dea d-band and the execution error, the watchdog timer can?t be clear by program. the watchdog is continuously counti ng until overflow occurrence. the overflow signal of watchdog timer triggers the system to reset, and the system return to normal mode after reset sequence. this method also can improve brown out reset condition and make sure the system to return normal mode. if the system reset by watchdog and the power is still in dead-band, the system reset sequence won?t be successful and the system stays in reset status until the power return to normal range. watchdog timer application note is as following. reduce the system executing rate: if the system rate is fast and the dead-band exists, to redu ce the system executing rate can improve the dead-band. the lower system rate is with lower minimum operating voltage. select the power voltage that?s no dead-band issue and find out the mapping system rate. adjust the system ra te to the value and the syst em exits the dead-band issue. this way needs to modify whole program timing to fit the application requirement. external reset circuit: the external reset methods also can improve brown out rese t and is the complete solution. there are three external reset circuits to improve brown out reset including ?zener di ode reset circuit?, ?voltage bias reset circuit? and ?external reset ic?. these three reset structures use external rese t signal and control to make sure the mcu be reset under power dropping and under dead-band. the external rese t information is described in the next section.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 43 version 1.4 3.5 external reset external reset function is controlled by ?reset_pin? c ode option. set the code option as ?reset? option to enable external reset function. external reset pin is schmitt trigge r structure and low level active. the system is running when reset pin is high level voltage input. the reset pin receives the low voltage and the system is reset. the external reset operation actives in power on and normal running mode. duri ng system power-up, the external reset pin must be high level input, or the system keeps in reset stat us. external reset sequence is as following. z external reset (only external reset pin enable): system checks external reset pin status. if external reset pin is not high level, the system keeps reset stat us and waits external reset pin released. z system initialization: all system registers is set as initia l conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and program executes from org 0. the external reset can reset the system during power on duration, and good external reset circuit can protect the system to avoid working at unusual power condition, e.g. brown out reset in ac power application? 3.6 external reset circuit 3.6.1 simply rc reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm c1 0.1uf r2 100 ohm this is the basic reset circuit, and only includes r1 and c1. the rc circuit operation makes a slow rising signal into reset pin as power up. the reset signal is slower than vdd power up timing, and system occurs a power on signal from the timing difference. ? note: the reset circuit is no any protection against unusual power or brown out reset.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 44 version 1.4 3.6.2 diode & rc reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm c1 0.1uf diode r2 100 ohm this is the better reset circuit. the r1 and c1 circuit operation is like the simply reset circuit to make a power on signal. the reset circuit has a simply protection against unusual po wer. the diode offers a power positive path to conduct higher power to vdd. it is can make reset pin voltage le vel to synchronize with v dd voltage. the structure can improve slight brown out reset condition. ? note: the r2 100 ohm resistor of ?simply reset circ uit? and ?diode & rc reset circuit? is necessar y to limit any current flowing into reset pin from external capacitor c in the event of reset pin breakdown due to electrostatic discharge (esd) or electrical over-stress (eos). 3.6.3 zener diode reset circuit mcu vdd vss vcc gnd r s t r1 33k ohm r3 40k ohm r2 10k ohm vz q1 e c b the zener diode reset circuit is a simple low voltage detector and can improve brown out reset condition completely . use zener voltage to be the active level. when vdd vo ltage level is above ?vz + 0. 7v?, the c terminal of the pnp transistor outputs high voltage and mcu operates normal ly. when vdd is below ?vz + 0.7v?, the c terminal of the pnp transistor outputs low voltage and mcu is in reset mode. decide the reset detect voltage by zener specification. select the right zene r voltage to conform the application.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 45 version 1.4 3.6.4 voltage bias reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm r3 2k ohm r2 10k ohm q1 e c b the voltage bias reset circuit is a low cost voltage detector and can improve brown out reset condition completely . the operating voltage is not accurate as zener diode reset ci rcuit. use r1, r2 bias voltage to be the active level. when vdd voltage level is above or equal to ?0.7v x (r1 + r2) / r1?, the c terminal of the pnp transistor outputs high voltage and mcu operates normally. when vdd is below ?0.7v x (r 1 + r2) / r1?, the c terminal of the pnp transistor outputs low voltage and mcu is in reset mode. decide the reset detect voltage by r1, r2 resistances. select the right r1, r2 value to conform the application. in the circuit diagram condition, the mcu?s reset pin level varies with vdd voltage variation, and the differential voltage is 0.7v. if the vdd drops and the voltage lower than reset pin det ect level, the system would be reset. if want to make the reset active earlier, set the r2 > r1 and the cap between vd d and c terminal voltage is larger than 0.7v. the external reset circuit is with a stable current through r1 and r2 . for power consumption issue application, e.g. dc power system, the current must be considered to whole system power consumption. ? note: under unstable power condition as brown out re set, ?zener diode rest circuit? and ?volta g e bias reset circuit? can protects s y stem no an y error occurrence as power droppin g . when power drops below the reset detect volta g e, the s y stem reset would be tri gg ered, and then s y stem executes reset sequence. that makes sure the system work well under unstable power situation.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 46 version 1.4 3.6.5 external reset ic mcu vdd vss vcc gnd r s t reset ic vdd vss rst bypass capacitor 0.1uf the external reset circuit also use external reset ic to enhance mcu reset performance. this is a high cost and good effect solution. by different application and system require ment to select suitable reset ic. the reset circuit can improve all power variation.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 47 version 1.4 4 4 4 system clock 4.1 overview the micro-controller is a dual clock sy stem. there are high-speed clock and low-speed clock. the high-speed clock is generated from the external oscillator circuit or on-chip 16mhz high-speed rc oscillator circuit (ihrc 16mhz). the low-speed clock is gen erated from on-chip low-speed rc oscillator circuit (ilrc 16khz @3v, 32khz @5v). both the high-speed clock and the low-sp eed clock can be system clock (fosc). the system clock in slow mode is divided by 4 to be the instruction cycle (fcpu). ) normal mode (high clock): fcpu = fhosc / n , n = 1 ~ 16, select n by fcpu code option. ) slow mode (low clock): fcpu = flosc/4. sonix provides a ?noise filter? controlled by code option. in high noisy sit uation, the noise filter can isolate noise outside and protect system works well. the mi nimum fcpu of high clock is limited at fhosc/4 when noise filter enable. 4.2 clock block diagram fhosc. fcpu = fhosc/1 ~ fhosc/16, noise filter disable. fcpu = fhosc/4 ~ fhosc/16, noise filter enable. flosc. fcpu = flosc/4 cpum[1:0] xin xout stphx hosc fcpu code option fosc fosc clkmd fcpu z hosc: high_clk code option. z fhosc: external high-speed clock / internal high-speed rc clock. z flosc: internal low-speed rc clock (about 16khz@3v, 32khz@5v). z fosc: system clock source. z fcpu: instruction cycle.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 48 version 1.4 4.3 oscm register the oscm register is an oscillator control regi ster. it controls oscillator status, system mode. 0cah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 oscm 0 0 0 cpum1 cpum0 clkmd stphx 0 read/write - - - r/w r/w r/w r/w - after reset - - - 0 0 0 0 - bit 1 stphx: external high-speed os cillator control bit. 0 = external high-speed oscillator free run. 1 = external high-speed oscillator free run stop. internal low-speed rc oscillator is still running. bit 2 clkmd: system high/low clock mode control bit. 0 = normal (dual) mode. syst em clock is high clock. 1 = slow mode. system clock is internal low clock. bit[4:3] cpum[1:0]: cpu operating mode control bits. 00 = normal. 01 = sleep (power down) mode. 10 = green mode. 11 = reserved. ? example: stop high-speed oscillator b0bset fstphx ; to stop exter nal high-speed oscillator only. ? example: when entering the power down mode (sl eep mode), both high-speed oscillator and internal low-speed oscillator will be stopped. b0bset fcpum0 ; to stop external high- speed oscillator and in ternal low-speed ; oscillator called powe r down mode (sleep mode).
SN8P2711 8-bit micro-controller sonix technology co., ltd page 49 version 1.4 4.4 system high clock the system high clock is from internal 16 mhz oscillator rc type or external oscilla tor. the high clock type is controlled by ?high_clk? code option. high_clk code option description ihrc the high clock is internal 16mhz oscillator rc type. xin and xout pins are general purpose i/o pins. rc the high clock is external rc type oscill ator. xout pin is general purpose i/o pin. 12m the high clock is external high speed o scillator. the typical frequency is 12mhz. 4m the high clock is external oscilla tor. the typical frequency is 4mhz. 4.4.1 internal high rc the chip is built-in rc type internal high clock (16mhz) controlled by ?ihrc_16m? c oed option. in ?ihrc_16m? mode, the system clock is from internal 16mhz rc type oscillator and xin / xout pins are general-purpose i/o pins. z ihrc: high clock is internal 16mhz oscillator rc ty pe. xin/xout pins are general-purpose i/o pins. 4.4.2 external high clock external high clock includes three modules (crystal/ceramic , rc and external clock signal). the high clock oscillator module is controlled by high_clk code option. the start up ti me of crystal/ceramic and rc type oscillator is different. rc type oscillator?s start-up time is very short, but the crystal?s is longer. the osci llator start-up time decides reset time length.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 50 version 1.4 4.4.2.1 crystal/ceramic crystal/ceramic devices are driven by xin, xout pins . for high/normal/low frequency, the driving currents are different. high_clk code option supports different frequencies. 12m option is for high speed (ex. 12mhz). 4m option is for normal speed (ex. 4mhz). mcu vcc gnd c 20pf xin x o u t vdd vss c 20pf crystal ? note: connect the crystal/ceramic and c as near as po ssible to the xin/xout/vss pins of micro-controller. 4.4.2.2 rc selecting rc oscillator is by rc option of high_clk code option. rc type oscillator?s frequenc y is up to 10mhz. using ?r? value is to change frequency. 50p~100p is good val ue for ?c?. xout pin is general purpose i/o pin. r mcu vcc gnd xin x o u t v d d vss c ? note: connect the r and c as near as possible to the vdd pin of micro-controller.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 51 version 1.4 4.4.2.3 external clock signal selecting external clock signal input to be system clock is by rc option of high_clk code opt ion. the external clock signal is input from xin pin. xout pin is general purpose i/o pin. mcu vcc gnd vss vdd xin xout external clock input ? note: the gnd of exte rnal oscillator circuit must be as near as possible to vss pin of micro-controller.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 52 version 1.4 4.5 system low clock the system low clock source is the internal low-speed oscill ator built in the micro-contro ller. the low-sp eed oscillator uses rc type oscillator circuit. the frequency is affect ed by the voltage and temperature of the system. in common condition, the frequency of the rc oscillator is about 16khz at 3v and 32khz at 5v. the relation between the rc frequency and voltage is as the following figure. internal low rc frequency 7.52 10.64 14.72 16.00 17.24 18.88 22.24 25.96 29.20 32.52 35.40 38.08 40.80 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 2.12.533.13.33.544.555.566.57 vdd (v) freq. (khz) ilrc the internal low rc supports watchdog clock source and system slow mode controlled by clkmd. ) flosc = internal low rc oscillator (about 16khz @3v, 32khz @5v). ) slow mode fcpu = flosc / 4 there are two conditions to stop internal low rc. one is power down mode, and the other is green mode of 32k mode and watchdog disable. if system is in 32k mode and watchdog disable, only 32k oscillator actives and system is under low power consumption. ? example: stop internal low-speed oscillator by power down mode. b0bset fcpum0 ; to stop external high- speed oscillator and in ternal low-speed ; oscillator called powe r down mode (sleep mode). ? note: the internal low-speed clock can?t be turned off individually. it is controlled by cpum0, cpum1 (32k, watchdog disable) bits of oscm register.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 53 version 1.4 4.5.1 system clock measurement under design period, the users can meas ure system clock speed by software instruction cycle (fcpu). this way is useful in rc mode. ? example: fcpu instruction cycl e of external oscillator. b0bset p0m.0 ; set p0.0 to be output mode for outputting fcpu toggle signal. @@: b0bset p0.0 ; output fcpu toggle signal in low-sp eed clock mode. b0bclr p0.0 ; measure the fcpu frequency by oscilloscope. jmp @b ? note: do not measure the rc frequency directly from xin; the probe impendence will affect the rc frequency.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 54 version 1.4 5 5 5 system operation mode 5.1 overview the chip is featured with low power consumption by switching around four different modes as following. z normal mode (high-speed mode) z slow mode (low-speed mode) z power-down mode (sleep mode) z green mode power down mode (sleep mode) slow mode green mode normal mode clkmd = 1 clkmd = 0 p0 wake-up function active. external reset circuit active. cpum1, cpum0 = 01. cpum1, cpum0 = 10. p0 wake-up function active. tc0 timer time out as tc0gn = 1. external reset circuit active. p0 wake-up function active. tc0 timer time out as tc0gn = 1. external reset circuit active. system mode switching diagram operating mode description mode normal slow green power down (sleep) remark ehosc running by stphx by stphx stop ihrc running by stphx by stphx stop ilrc running running running stop cpu instruction executi ng executing stop stop tc0 timer *active *activ e *active inactive *a ctive if tc0enb = 1 tc1 timer *active *activ e *active inactive *a ctive if tc1enb = 1 watchdog timer by watch_dog code option by watch_dog code option by watch_dog code option by watch_dog code option refer to code option description internal interrupt all active all active tc0, tc1 all inactive external interrupt all active all active all active all active wakeup source - - p0, tc0 reset p0, reset ehosc : external high clock ihrc : internal high clock (16m rc oscillator) ilrc : internal low clock (16k rc oscillator at 3v, 32k at 5v)
SN8P2711 8-bit micro-controller sonix technology co., ltd page 55 version 1.4 5.2 system mode switching example ? example: switch normal/slow mode to power down (sleep) mode. b0bset fcpum0 ; set cpum0 = 1. ? note: during the sleep, only the wakeup pin and reset can wakeup the system back to the normal mode. ? example: switch normal mode to slow mode. b0bset fclkmd ;to set clkmd = 1, change the system into slow mode b0bset fstphx ;to stop external high -speed oscillator for power saving. ? example: switch slow mode to normal mode ( the external high-speed oscillator is still running). b0bclr fclkmd ;to set clkmd = 0 ? example: switch slow mode to normal mode (the external high-speed oscillator stops). if external high clock stop and program want to switch back normal mode. it is necessary to delay at least 20ms for external clock stable. b0bclr fstphx ; turn on the external high-speed oscillator. mov a, #54 ; if vdd = 5v, internal rc=32khz (typical) will delay b0mov z, a @@: decms z ; 0.125ms x 162 = 20.25ms for external clock stable jmp @b b0bclr fclkmd ; change the system back to the normal mode ? example: switch normal/slow mode to green mode. b0bset fcpum1 ; set cpum1 = 1. ? note: if tc0 timer wakeup function is disabled in the green mode, only the wakeup pin and reset pin can wakeup the system backs to the previous operation mode.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 56 version 1.4 ? example: switch normal/slow mode to green mode and enable tc0 wake-up function. ; set t0 timer wakeup function. b0bclr ftc0ien ; to disable tc0 interrupt service b0bclr ftc0enb ; to disable tc0 timer mov a,#20h ; b0mov tc0m,a ; to set tc0 clock = fcpu / 64 mov a,#74h b0mov tc0c,a ; to set tc0c initial value = 74h (to set tc0 interval = 10 ms) b0bclr ftc0ien ; to disable tc0 interrupt service b0bclr ftc0irq ; to clear tc0 interrupt request b0bset ftc0gn ; to enable tc0 timer wake-up function. b0bset ftc0enb ; to enable tc0 timer ; go into green mode b0bclr fcpum0 ;to set cpumx = 10 b0bset fcpum1 ? note: during the green mode with tc0 wake-up function, the wakeup pins and tc0 can wakeup the system back to the last mode. tc0 wake-up period is controlled by program and tc0gn must be set. 0d8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0m - - - - tc1x8 tc0x8 tc0gn - read/write - - - - r/w r/w r/w - after reset - - - - 0 0 0 - bit 1 tc0gn: tc0 green mode wake-up function control bits. 0 = disable. 1 = enable.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 57 version 1.4 5.3 wakeup 5.3.1 overview under power down mode (sleep mode) or green mode, progra m doesn?t execute. the wakeup trigger can wake the system up to normal mode or slow mode. the wakeup tri gger sources are external trigger (p0 level change) and internal trigger (tc0 timer overflow). z power down mode is waked up to normal mode. the wakeup trigger is only external trigger (p0 level change) z green mode is waked up to last mode (normal mode or slow mode). the wakeup triggers are external trigger (p0 level change) and internal trigger (tc0 timer overflow). 5.3.2 wakeup time when the system is in power down mo de (sleep mode), the high clock oscilla tor stops. when wake d up from power down mode, mcu waits for 2048 exte rnal high-speed oscillator clocks as the wake up time to stable the oscillator circuit. after the wakeup time, the system goes into the normal mode. ? note: wakeup from green mode is no wakeup time because the clock doesn?t stop in green mode. the value of the wakeup time is as the following. the wakeup time = 1/fosc * 2048 (sec) + high clock start-up time ? note: the high clock start-up time is depended on the vdd and o scillator type of high clock. ? example: in power down mode (sleep mode), the sy stem is waked up. after the wakeup time, the system goes into normal mode. the wakeup time is as the following. the wakeup time = 1/fosc * 2048 = 0.512 ms (fosc = 4mhz) the total wakeup time = 0.512ms + oscillator start-up time
SN8P2711 8-bit micro-controller sonix technology co., ltd page 58 version 1.4 6 6 6 interrupt 6.1 overview this mcu provides five interrupt sources, including three internal interrupt (tc0/tc1/adc) and two external interrupt (int0/int1). the external interrupt ca n wakeup the chip while the system is switched from power down mode to high-speed normal mode, and interrupt request is latched until return to normal mode. once interrupt service is executed, the gie bit in stkp register will clear to ?0? fo r stopping other interrupt requ est. on the contrast, when interrupt service exit s, the gie bit will set to ?1? to accept the next in terrupts? request. all of th e interrupt re quest signa ls are stored in intrq register. inten interrupt enable register interrupt enable gating intrq 5-bit latchs p00irq p01irq tc0irq tc1irq adcirq interrupt vector address (0008h) global interrupt request signal int0 trigger int1 trigger tc0 time out tc1 time out adc converting successfully ? note: the gie bit must enable during all interrupt operation.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 59 version 1.4 6.2 inten interrupt enable register inten is the interrupt request control re gister including three internal interrupts , two external interrupts enable control bits. one of the register to be set ?1? is to enable the interrupt request function. once of the interrupt occur, the stack is incremented and program jump to org 8 to execute interrupt service routines. t he program exits the interrupt service routine when the returning interrupt service routine instruction (reti) is executed. 0c9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 inten adcien tc1ien tc0ien - - - p01ien p00ien read/write r/w r/w r/w - - - r/w r/w after reset 0 0 0 - - - 0 0 bit 0 p00ien: external p0.0 interrupt (int0) control bit. 0 = disable int0 interrupt function. 1 = enable int0 interrupt function. bit 1 p01ien: external p0.1 interrupt (int1) control bit. 0 = disable int1 interrupt function. 1 = enable int1 interrupt function. bit 5 tc0ien: tc0 timer interrupt control bit. 0 = disable tc0 interrupt function. 1 = enable tc0 interrupt function. bit 6 tc1ien: tc1 timer interrupt control bit. 0 = disable tc1 interrupt function. 1 = enable tc1 interrupt function. bit 7 adcien: adc interrupt control bit. 0 = disable adc interrupt function. 1 = enable adc interrupt function.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 60 version 1.4 6.3 intrq interrupt request register intrq is the interrupt request flag register. the register incl udes all interrupt request indication flags. each one of the interrupt requests occurs, the bit of the intrq register would be set ?1?. the intrq value needs to be clear by programming after detecting the flag. in the interrupt vect or of program, users know the any interrupt requests occurring by the register and do the routi ne corresponding of the interrupt request. 0c8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 intrq adcirq tc1irq tc0irq - - - p01irq p00irq read/write r/w r/w r/w - - - r/w r/w after reset 0 0 0 - - - 0 0 bit 0 p00irq: external p0.0 interrupt (int0) request flag. 0 = none int0 interrupt request. 1 = int0 interrupt request. bit 1 p01irq: external p0.1 interrupt (int1) request flag. 0 = none int1 interrupt request. 1 = int1 interrupt request. bit 5 tc0irq: tc0 timer interrupt request flag. 0 = none tc0 interrupt request. 1 = tc0 interrupt request. bit 6 tc1irq: tc1 timer interrupt request flag. 0 = none tc1 interrupt request. 1 = tc1 interrupt request. bit 7 adcirq: adc interrupt request flag. 0 = none adc interrupt request. 1 = adc interrupt request.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 61 version 1.4 6.4 gie global interrupt operation gie is the global interrupt control bit. all interrupts start wo rk after the gie = 1 it is necessary for interrupt service request. one of the interrupt requests occurs, and the program co unter (pc) points to the interrupt vector (org 8) and the stack add 1 level. 0dfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie - - - - stkpb2 stkpb1 stkpb0 read/write r/w - - - - r/w r/w r/w after reset 0 - - - - 1 1 1 bit 7 gie: global interrupt control bit. 0 = disable global interrupt. 1 = enable global interrupt. ? example: set global interrupt control bit (gie). b0bset fgie ; enable gie ? note: the gie bit must enable during all interrupt operation.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 62 version 1.4 6.5 push, pop routine when any interrupt occurs, system will jump to org 8 and ex ecute interrupt service routine. it is necessary to save acc, pflag data. the chip includes ?push?, ?pop? for in/ out interrupt service routine. the two instruction save and load acc , pflag data into buffers and avoid main routine erro r after interrupt service routine finishing. ? note: ?push?, ?pop? instructions save and load a cc/pflag without (nt0, npd). push/pop buffer is an unique buffer and only one level. ? example: store acc and paflg data by push, po p instructions when interrupt service routine executed. org 0 jmp start org 8 jmp int_service org 10h start: ? int_service: push ; save acc and pflag to buffers. ? ? pop ; load acc and pflag from buffers. reti ; exit interrupt service vector ? endp
SN8P2711 8-bit micro-controller sonix technology co., ltd page 63 version 1.4 6.6 int0 (p0.0) interrupt operation when the int0 trigger occurs, the p00irq will be set to ?1 ? no matter the p00ien is enable or disable. if the p00ien = 1 and the trigger event p00irq is also set to be ?1?. as t he result, the system will execute the interrupt vector (org 8). if the p00ien = 0 and the trigger event p00irq is still se t to be ?1?. moreover, the sy stem won?t execute interrupt vector even when the p00irq is set to be ?1?. users need to be cautious with the operation under multi-interrupt situation. if the interrupt trigger direction is identical with wake-up tr igger direction, the int0 inte rrupt request flag (int0irq) is latched while system wake-up from power down mode or gr een mode by p0.0 wake-up trigger. system inserts to interrupt vector (org 8) after wake-up immediately. ? note: int0 interrupt request can be latched by p0.0 wake-up trigger. ? note: the interrupt trigger direction of p0.0 is control by pedge register. 0bfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pedge - - - p00g1 p00g0 - - - read/write - - - r/w r/w - - - after reset - - - 1 0 - - - bit[4:3] p00g[1:0]: p0.0 interrupt trigger edge control bits. 00 = reserved. 01 = rising edge. 10 = falling edge. 11 = rising/falling bi-direction (level change trigger). ? example: setup int0 interrupt request and bi-direction edge trigger. mov a, #18h b0mov pedge, a ; set int0 interr upt trigger as bi-direction edge. b0bset fp00ien ; enable int0 interrupt service b0bclr fp00irq ; clear int0 interrupt request flag b0bset fgie ; enable gie
SN8P2711 8-bit micro-controller sonix technology co., ltd page 64 version 1.4 ? example: int0 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 fp00irq ; check p00irq jmp exit_int ; p00irq = 0, exit interrupt vector b0bclr fp00irq ; reset p00irq ? ; int0 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8P2711 8-bit micro-controller sonix technology co., ltd page 65 version 1.4 6.7 int1 (p0.1) interrupt operation when the int1 trigger occurs, the p01irq will be set to ?1 ? no matter the p01ien is enable or disable. if the p01ien = 1 and the trigger event p01irq is also set to be ?1?. as t he result, the system will execute the interrupt vector (org 8). if the p01ien = 0 and the trigger event p01irq is still se t to be ?1?. moreover, the sy stem won?t execute interrupt vector even when the p01irq is set to be ?1?. users need to be cautious with the operation under multi-interrupt situation. if the interrupt trigger direction is identical with wake-up tr igger direction, the int1 inte rrupt request flag (int1irq) is latched while system wake-up from power down mode or gr een mode by p0.1 wake-up trigger. system inserts to interrupt vector (org 8) after wake-up immediately. ? note: int1 interrupt request can be latched by p0.1 wake-up trigger. ? note: the interrupt trigger dir ection of p0.1 is falling edge. ? example: int1 interrupt request setup. b0bset fp01ien ; enable int1 interrupt service b0bclr fp01irq ; clear int1 interrupt request flag b0bset fgie ; enable gie ? example: int1 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 fp01irq ; check p01irq jmp exit_int ; p01irq = 0, exit interrupt vector b0bclr fp01irq ; reset p01irq ? ; int1 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8P2711 8-bit micro-controller sonix technology co., ltd page 66 version 1.4 6.8 tc0 interrupt operation when the tc0c counter overflows, the tc0irq will be set to ?1? no matter the tc0ien is enable or disable. if the tc0ien and the trigger event tc0irq is set to be ?1?. as t he result, the system will execute the interrupt vector. if the tc0ien = 0, the trigger event tc0irq is still set to be ?1?. moreover, the system won?t execute interrupt vector even when the tc0ien is set to be ?1?. users need to be cautio us with the operation under multi-interrupt situation. ? example: tc0 interrupt request setup. b0bclr ftc0ien ; disable tc0 interrupt service b0bclr ftc0enb ; disable tc0 timer mov a, #20h ; b0mov tc0m, a ; set tc0 clock = fcpu / 64 mov a, #74h ; set tc0c initial value = 74h b0mov tc0c, a ; set tc0 interval = 10 ms b0bset ftc0ien ; enable tc0 interrupt service b0bclr ftc0irq ; clear tc0 interrupt request flag b0bset ftc0enb ; enable tc0 timer b0bset fgie ; enable gie ? example: tc0 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 ftc0irq ; check tc0irq jmp exit_int ; tc0irq = 0, exit interrupt vector b0bclr ftc0irq ; reset tc0irq mov a, #74h b0mov tc0c, a ; reset tc0c. ? ; tc0 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8P2711 8-bit micro-controller sonix technology co., ltd page 67 version 1.4 6.9 tc1 interrupt operation when the tc1c counter overflows, the tc1irq will be set to ?1? no matter the tc1ien is enable or disable. if the tc1ien and the trigger event tc1irq is set to be ?1?. as t he result, the system will execute the interrupt vector. if the tc1ien = 0, the trigger event tc1irq is still set to be ?1?. moreover, the system won?t execute interrupt vector even when the tc1ien is set to be ?1?. users need to be cautio us with the operation under multi-interrupt situation. ? example: tc1 interrupt request setup. b0bclr ftc1ien ; disable tc1 interrupt service b0bclr ftc1enb ; disable tc1 timer mov a, #20h ; b0mov tc1m, a ; set tc1 clock = fcpu / 64 mov a, #74h ; set tc1c initial value = 74h b0mov tc1c, a ; set tc1 interval = 10 ms b0bset ftc1ien ; enable tc1 interrupt service b0bclr ftc1irq ; clear tc1 interrupt request flag b0bset ftc1enb ; enable tc1 timer b0bset fgie ; enable gie ? example: tc1 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 ftc1irq ; check tc1irq jmp exit_int ; tc1irq = 0, exit interrupt vector b0bclr ftc1irq ; reset tc1irq mov a, #74h b0mov tc1c, a ; reset tc1c. ? ; tc1 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8P2711 8-bit micro-controller sonix technology co., ltd page 68 version 1.4
SN8P2711 8-bit micro-controller sonix technology co., ltd page 69 version 1.4 6.10 adc interrupt operation when the adc converting succes sfully, the adcirq will be set to ?1? no matte r the adcien is enable or disable. if the adcien and the trigger ev ent adcirq is set to be ?1?. as the result, the system will execute the interrupt vector. if the adcien = 0, the trigger event adcirq is still set to be ?1?. moreover, the system won?t execut e interrupt vector even when the adcien is set to be ?1?. users need to be caut ious with the operation under multi-interrupt situation. ? example: adc interrupt request setup. b0bclr fadcien ; disable adc interrupt service mov a, #10110000b ; b0mov adm, a ; enable p4.0 adc input and adc function. mov a, #00000000b ; set adc converting rate = fcpu/16 b0mov adr, a b0bset fadcien ; enable adc interrupt service b0bclr fadcirq ; clear adc interrupt request flag b0bset fgie ; enable gie b0bset fads ; start adc transformation ? example: adc interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 fadcirq ; check adcirq jmp exit_int ; adcirq = 0, exit interrupt vector b0bclr fadcirq ; reset adcirq ? ; adc interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8P2711 8-bit micro-controller sonix technology co., ltd page 70 version 1.4 6.11 multi-interrupt operation under certain condition, the software designer uses more than one interrupt requests. processing multi-interrupt request requires setting the priority of the interrupt requests. the irq flags of interrupts are controlled by the interrupt event. nevertheless, the irq flag ?1? doesn?t mean the syst em will execute the interrupt vector. in addition, which means the irq flags can be set ?1? by the events without enable the interrupt. once the event occurs, the irq will be logic ?1?. the irq and its trigger event relationship is as the below table. interrupt name trigger event description p00irq p0.0 trigger controlled by pedge. p01irq p0.1 falling edge trigger. tc0irq tc0c overflow. tc1irq tc1c overflow. adcirq adc converting successfully. for multi-interrupt conditions, two things need to be taking care of. one is to set the priority for these interrupt requests. two is using ien and irq flags to decide which interrupt to be executed. users have to check interrupt control bit and interrupt request flag in interrupt routine. ? example: check the interrupt request under multi-interrupt operation org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. intp00chk: ; check int0 interrupt request b0bts1 fp00ien ; check p00ien jmp intp01chk ; jump check to next interrupt b0bts0 fp00irq ; check p00irq jmp intp00 ; jump to int0 interrupt service routine intp01chk: ; check int0 interrupt request b0bts1 fp01ien ; check p01ien jmp inttc0chk ; jump check to next interrupt b0bts0 fp01irq ; check p01irq jmp intp01 ; jump to int1 interrupt service routine inttc0chk: ; check tc0 interrupt request b0bts1 ftc0ien ; check tc0ien jmp inttc1chk ; jump check to next interrupt b0bts0 ftc0irq ; check tc0irq jmp inttc0 ; jump to tc0 interrupt service routine inttc1chk: ; check tc1 interrupt request b0bts1 ftc1ien ; check tc1ien jmp intadchk ; jump check to next interrupt b0bts0 ftc1irq ; check tc1irq jmp inttc1 ; jump to tc1 interrupt service routine intadchk: ; check adc interrupt request b0bts1 fadcien ; check adcien jmp int_exit ; jump to exit of irq b0bts0 fadcirq ; check adcirq jmp intadc ; jump to adc interrupt service routine int_exit: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8P2711 8-bit micro-controller sonix technology co., ltd page 71 version 1.4 7 7 7 i/o port 7.1 i/o port mode the port direction is programmed by pnm register. a ll i/o ports can select input or output direction. 0b8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0m - - - - p03m p02m p01m p00m read/write - - - - r/w r/w r/w r/w after reset - - - - 0 0 0 0 0c4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4m - - - p44m p43m p42m p42m p40m read/write - - - r/w r/w r/w r/w r/w after reset - - - 0 0 0 0 0 0c5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5m - - - p54m p53m - - - read/write - - - r/w r/w - - - after reset - - - 0 0 - - - bit[7:0] pnm[7:0]: pn mode control bits. (n = 0~5). 0 = pn is input mode. 1 = pn is output mode. ? note: 1. users can program them by bit c ontrol instructions (b0bset, b0bclr). 2. p0.4 input only pin, and the p0m.4 keeps ?1?. ? example: i/o mode selecting clr p0m ; set all ports to be input mode. clr p4m clr p5m mov a, #0ffh ; set all ports to be output mode. b0mov p0m, a b0mov p4m,a b0mov p5m, a b0bclr p4m.0 ; set p4.0 to be input mode. b0bset p4m.0 ; set p4.0 to be output mode.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 72 version 1.4 7.2 i/o pull up register 0e0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0ur - - - - p03r p02r p01r p00r read/write - - - - w w w w after reset - - - - 0 0 0 0 0e4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4ur - - - p44r p43r p42r p41r p40r read/write - - - w w w w w after reset - - - 0 0 0 0 0 0e5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5ur - - - p54r p53r - - - read/write - - - w w - - - after reset - - - 0 0 - - - ? note: p0.4 is input only pin and without pull-up resister. the p0ur.4 keeps ?1?. ? example: i/o pull up register mov a, #0ffh ; enable port0, 4, 5 pull-up register, b0mov p0ur, a ; b0mov p4ur,a b0mov p5ur, a
SN8P2711 8-bit micro-controller sonix technology co., ltd page 73 version 1.4 7.3 i/o port data register 0d0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0 - - - p04 p03 p02 p01 p00 read/write - - - r r/w r/w r/w r/w after reset - - - 0 0 0 0 0 0d4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4 - - - p44 p43 p42 p41 p40 read/write - - - r/w r/w r/w r/w r/w after reset - - - 0 0 0 0 0 0d5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5 - - - p54 p53 - - - read/write - - - r/w r/w - - - after reset - - - 0 0 - - - ? note: the p04 keeps ?1? when external reset enable by code option. ? example: read data from input port. b0mov a, p0 ; read data from port 0 b0mov a, p4 ; read data from port 4 b0mov a, p5 ; read data from port 5 ? example: write data to output port. mov a, #0ffh ; write data ffh to all port. b0mov p0, a b0mov p4, a b0mov p5, a ? example: write one bit data to output port. b0bset p4.0 ; set p4.0 and p5.3 to be ?1?. b0bset p5.3 b0bclr p4.0 ; set p4.0 and p5.3 to be ?0?. b0bclr p5.3
SN8P2711 8-bit micro-controller sonix technology co., ltd page 74 version 1.4 7.4 port 4 adc share pin the port 4 is shared with adc input function and no schmitt tr igger structure. only one pin of port 4 can be configured as adc input in the same time by adm register. the other pins of port 4 are digital i/o pins. connect an analog signal to coms digital input pin, especially the analog signal leve l is about 1/2 vdd will cause extra current leakage. in the power down mode, the above leakage curre nt will be a big problem. unfortunatel y, if users connect more than one analog input signal to port 4 will encounter above current leakage situation. p4con is port4 configuration register. write ?1? into p4con.n will configure related port 4 pi n as pure analog input pin to avoid current leakage. 0aeh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4con - - - p4con4 p4con3 p4con2 p4con1 p4con0 read/write - - - r/w r/w r/w r/w r/w after reset - - - 0 0 0 0 0 bit[4:0] p4con[4:0]: p4.n configuration control bits. 0 = p4.n can be an analog input (adc input) or digital i/o pins. 1 = p4.n is pure analog input, can?t be a digital i/o pin. ? note: when port 4.n is general i/o port not adc channel, p4con.n must set to ?0? or the port 4.n digital i/o signal would be isolated. port 4 adc analog input is controlled by gchs and chsn bits of adm register. if gchs = 0, p4.n is general purpose bi-direction i/o port. if gchs = 1, p4.n pointed by chsn is adc analog signal input pin. 0b1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adm adenb ads eoc gchs - chs2 chs1 chs0 read/write r/w r/w r/ w r/w - r/w r/w r/w after reset 0 0 0 0 - 0 0 0 bit 4 gchs: global channel select bit. 0 = disable ain channel. 1 = enable ain channel. bit[2:0] chs[2:0]: adc input channels select bit. 000 = ain0, 001 = ain1, 010 = ain2, 011 = ain3, 100 = ain4, 101 = ain5. ? note: for p4.n general purpose i/o function, users should make sure of p4.n?s adc channel is disabled, or p4.n is automatically set as adc analog input when gchs = 1 and chs[2:0] point to p4.n.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 75 version 1.4 ? example: set p4.1 to be general purpose input mode. p4con.1 must be set as ?0?. ; check gchs and chs[2:0] status. b0bclr fgchs ;if chs[2:0] point to p4.1 (chs[2:0] = 001b), set gchs=0 ;if chs[2:0] don?t point to p4.1 (chs[2:0] 001b), don?t care gchs status. ; clear p4con. b0bclr p4con.1 ; enable p4.1 digital function. ; enable p4.1 input mode. b0bclr p4m.1 ; set p4.1 as input mode. ? example: set p4.1 to be general purpose output. p4con.1 must be set as ?0?. ; check gchs and chs[2:0] status. b0bclr fgchs ;if chs[2:0] point to p4.1 (chs[2:0] = 001b), set gchs=0. ;if chs[2:0] don?t point to p4.1 (chs[2:0] 001b), don?t care gchs status. ; clear p4con. b0bclr p4con.1 ; enable p4.1 digital function. ; set p4.1 output buffer to avoid glitch. b0bset p4.1 ; set p4.1 buffer as ?1?. ; or b0bclr p4.1 ; set p4.1 buffer as ?0?. ; enable p4.1 output mode. b0bset p4m.1 ; set p4.1 as input mode.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 76 version 1.4 p4.0 is shared with general purpose i/o, adc input (a in0) and adc external high reference voltage input. evhenb flag of vrefh register is external adc high reference vo ltage input control bit. if evhenb is enabled, p4.0 general purpose i/o and adc analog input (ain0) functions are disabl ed. p4.0 pin is connected to adc high reference voltage directly. ? note: for p4.0 general purpose i/o and ain0 functions, evhenb must be set as ?0?. 0afh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 vrefh evhenb - - - - - vhs1 vhs0 read/write r/w - - - - - r/w r/w after reset 0 - - - - - 0 0 bit 7 evhenb: external adc high reference voltage input control bit. 0 = disable adc external high reference voltage input. 1 = enable adc external high reference voltage input. ? example: set p4.0 to be general purpose input mode. evhenb and p4con.0 bits must be set as ?0?. ; check evhenb status. b0bts0 fevhenb ; check evhenb = 0. b0bclr fevhenb ; evhenb = 1, clear it to disable external adc high reference input. ; evhenb = 0, execute next routine. ; check gchs and chs[2:0] status. b0bclr fgchs ;if chs[2:0] point to p4.0 (chs[2:0] = 000b), set gchs=0 ;if chs[2:0] don?t point to p4.0 (chs[2:0] 000b), don?t care gchs status. ; clear p4con. b0bclr p4con.0 ; enable p4.0 digital function. ; enable p4.0 input mode. b0bclr p4m.0 ; set p4.0 as input mode.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 77 version 1.4 ? example: set p4.0 to be general purpose output. evhenb and p4con.0 bits must be set as ?0?. ; check evhenb status. b0bts0 fevhenb ; check evhenb = 0. b0bclr fevhenb ; evhenb = 1, clear it to disable external adc high reference input. ; evhenb = 0, execute next routine. ; check gchs and chs[2:0] status. b0bclr fgchs ;if chs[2:0] point to p4.0 (chs[2:0] = 000b), set gchs=0 ;if chs[2:0] don?t point to p4.0 (chs[2:0] 000b), don?t care gchs status. ; clear p4con. b0bclr p4con.0 ; enable p4.0 digital function. ; set p4.0 output buffer to avoid glitch. b0bset p4.0 ; set p4.0 buffer as ?1?. ; or b0bclr p4.0 ; set p4.0 buffer as ?0?. ; enable p4.0 output mode. b0bset p4m.0 ; set p4.0 as input mode.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 78 version 1.4 8 8 8 timers 8.1 watchdog timer the watchdog timer (wdt) is a binary up counter designed for monitoring program execution. if the program goes into the unknown status by noise interferen ce, wdt overflow signal raises and resets mcu. watchdog clock controlled by code option and the clock source is internal low-speed oscillator (16khz @3v, 32khz @5v). watchdog overflow time = 8192 / inte rnal low-speed oscillator (sec). vdd internal low rc freq. watchdog overflow time 3v 16khz 512ms 5v 32khz 256ms ? note: if watchdog is ?always_on? mode, it keeps running event under power down mode or green mode. watchdog clear is controlled by wdtr register. moving 0x5a data into wdtr is to reset watchdog timer. 0cch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 wdtr wdtr7 wdtr6 wdtr5 wdtr4 wdtr3 wdtr2 wdtr1 wdtr0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 ? example: an operation of watchdog timer is as following. to clear the watchdog timer counter in the top of the main routine of the program. main: mov a,#5ah ; clear the watchdog timer. b0mov wdtr,a ? call sub1 call sub2 ? ? ? jmp main
SN8P2711 8-bit micro-controller sonix technology co., ltd page 79 version 1.4 watchdog timer application note is as following. z before clearing watchdog timer, check i/o status and check ram contents c an improve system error. z don?t clear watchdog timer in interrupt vector and interrupt service routine. that can improve main routine fail. z clearing watchdog timer program is only at one part of the program. this way is the best structure to enhance the watchdog timer function. ? example: an operation of watchdog timer is as following. to clear the watchdog timer counter in the top of the main routine of the program. main: ? ; check i/o. ? ; check ram err: jmp $ ; i/o or ram error. program jump here and don?t ; clear watchdog. wait watchdog timer overflow to reset ic. correct: ; i/o and ram are correct. clear watchdog timer and ; execute program. b0bset fwdrst ; only one clearing watchdog timer of whole program. ? call sub1 call sub2 ? ? ? jmp main
SN8P2711 8-bit micro-controller sonix technology co., ltd page 80 version 1.4
SN8P2711 8-bit micro-controller sonix technology co., ltd page 81 version 1.4 8.2 timer/counter 0 (tc0) 8.2.1 overview the tc0 is an 8-bit binary up counting timer with double buffers. tc0 has two clock sources including internal clock and external clock for counting a precision time. the internal clock source is from fcpu or fosc controlled by tc0x8 flag to get faster clock source (fosc). the external clock is int0 from p0.0 pin (falling edge trigger). using tc0m register selects tc0c?s clock source from internal or external. if tc0 timer occurs an overflow, it will continue counting and issue a time-out signal to trigger tc0 interrupt to requ est interrupt service. tc0 overflow time is 0xff to 0x00 normally. under pwm mode, tc0 overflow is decided by pwm cycle controlled by aload0 and tc0out bits. the main purposes of the tc0 timer is as following. ) 8-bit programmable up counting timer: generates interrupts at specific time intervals based on the selected clock frequency. ) external event counter: counts system ?events? based on falling edge detection of external clock signals at the int0 input pin. ) green mode wake-up function: tc0 can be green mode wake-up timer. system will be wake-up by tc0 time out. ) buzzer output ) pwm output fcpu tc0 rate (fcpu/2~fcpu/256) fosc tc0 rate (fosc/1~fosc/128) tc0x8 int0 (schmitter trigger) tc0cks tc0enb cpum0,1 tc0c 8-bit binary up counting counter tc0r reload data buffer up counting reload value tc0 time out compare aload0 r s tc0 time out auto. reload tc0 / 2 buzzer internal p5.4 i/o circuit p5.4 pwm pwm0out tc0out aload0, tc0out load
SN8P2711 8-bit micro-controller sonix technology co., ltd page 82 version 1.4 8.2.2 tc0m mode register 0dah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0m tc0enb tc0rate2 tc0rate1 tc0rate0 tc0cks aload0 tc0out pwm0out read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 0 pwm0out: pwm output control bit. 0 = disable pwm output. 1 = enable pwm output. pwm duty controlled by tc0out, aload0 bits. bit 1 tc0out: tc0 time out toggle signal output control bit. only valid when pwm0out = 0. 0 = disable, p5.4 is i/o function. 1 = enable, p5.4 is output tc0out signal. bit 2 aload0: auto-reload control bit. only valid when pwm0out = 0. 0 = disable tc0 auto-reload function. 1 = enable tc0 auto-reload function. bit 3 tc0cks: tc0 clock source select bit. 0 = internal clock (fcpu or fosc). 1 = external clock from p0.0/int0 pin. bit [6:4] tc0rate[2:0]: tc0 internal clock select bits. tc0rate [2:0] tc0x8 = 0 tc0x8 = 1 000 fcpu / 256 fosc / 128 001 fcpu / 128 fosc / 64 010 fcpu / 64 fosc / 32 011 fcpu / 32 fosc / 16 100 fcpu / 16 fosc / 8 101 fcpu / 8 fosc / 4 110 fcpu / 4 fosc / 2 111 fcpu / 2 fosc / 1 bit 7 tc0enb: tc0 counter control bit. 0 = disable tc0 timer. 1 = enable tc0 timer. ? note: when tc0cks=1, tc0 became an external event counter and tc0rate is useless. no more p0.0 interrupt request will be raised. (p0.0irq will be always 0).
SN8P2711 8-bit micro-controller sonix technology co., ltd page 83 version 1.4 8.2.3 tc1x8, tc0x8, tc0gn flags 0d8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0m - - - - tc1x8 tc0x8 tc0gn - read/write - - - - r/w r/w r/w - after reset - - - - 0 0 0 - bit 1 tc0gn: tc0 green mode wake-up function control bit. 0 = disable tc0 green mode wake-up function. 1 = enable tc0 green mode wake-up function. bit 2 tc0x8: tc0 internal clock source control bit. 0 = tc0 internal clock source is fcpu. tc0rate is from fcpu/2~fcpu/256. 1 = tc0 internal clock source is fo sc. tc0rate is from fosc/1~fosc/128. bit 3 tc1x8: tc1 internal clock source control bit. 0 = tc1 internal clock source is fcpu. tc1rate is from fcpu/2~fcpu/256. 1 = tc1 internal clock source is fo sc. tc1rate is from fosc/1~fosc/128. ? note: under tc0 event counter mode (tc0ck s=1), tc0x8 bit and tc0rate are useless. 8.2.4 tc0c counting register tc0c is an 8-bit counter register for tc0 interval time control. 0dbh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0c tc0c7 tc0c6 tc0c5 tc0c4 tc0c3 tc0c2 tc0c1 tc0c0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of tc0c initial value is as following. tc0c initial value = n - (tc0 interrupt interval time * input clock) n is tc0 overflow boundary number. tc0 timer overflow time has six types (tc0 timer, tc0 event counter, tc0 fcpu clock source, tc0 fosc clock source, pwm mode and no pw m mode). these parameters decide tc0 overflow time and valid value as follow table. tc0cks tc0x8 pwm0 aload0 tc0out n tc0c valid value tc0c value binary type remark 0 x x 256 0x00~0xff 00000000b~11111111b overflow per 256 count 1 0 0 256 0x00~0xff 00000000b~11111111b overflow per 256 count 1 0 1 64 0x00~0x3f xx000000b~xx111111b overflow per 64 count 1 1 0 32 0x00~0x1f xxx00000b~xxx11111b overflow per 32 count 0 (fcpu/2~ fcpu/256) 1 1 1 16 0x00~0x0f xxxx0000b~xxxx1111b overflow per 16 count 0 x x 256 0x00~0xff 00000000b~11111111b overflow per 256 count 1 0 0 256 0x00~0xff 00000000b~11111111b overflow per 256 count 1 0 1 64 0x00~0x3f xx000000b~xx111111b overflow per 64 count 1 1 0 32 0x00~0x1f xxx00000b~xxx11111b overflow per 32 count 0 1 (fosc/1~ fosc/128) 1 1 1 16 0x00~0x0f xxxx0000b~xxxx1111b overflow per 16 count 1 - - - - 256 0x00~0xff 00000000b~11111111b overflow per 256 count
SN8P2711 8-bit micro-controller sonix technology co., ltd page 84 version 1.4 ? example: to set 10ms interval time for tc0 interr upt. tc0 clock source is fcpu (tc0ks=0, tc0x8=0) and no pwm output (pwm0=0). high clock is external 4mhz . fcpu=fosc/4. select tc0rate=010 (fcpu/64). tc0c initial value = n - (tc0 interrupt interval time * input clock) = 256 - (10ms * 4mhz / 4 / 64) = 256 - (10 -2 * 4 * 10 6 / 4 / 64) = 100 = 64h the basic timer table interval time of tc0, tc0x8 = 0. high speed mode (fcpu = 4mhz / 4) low speed mode (fcpu = 32768hz / 4) tc0rate tc0clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fcpu/256 65.536 ms 256 us 8000 ms 31250 us 001 fcpu/128 32.768 ms 128 us 4000 ms 15625 us 010 fcpu/64 16.384 ms 64 us 2000 ms 7812.5 us 011 fcpu/32 8.192 ms 32 us 1000 ms 3906.25 us 100 fcpu/16 4.096 ms 16 us 500 ms 1953.125 us 101 fcpu/8 2.048 ms 8 us 250 ms 976.563 us 110 fcpu/4 1.024 ms 4 us 125 ms 488.281 us 111 fcpu/2 0.512 ms 2 us 62.5 ms 244.141 us the basic timer table interval time of tc0, tc0x8 = 1. high speed mode (fcpu = 4mhz / 4) low speed mode (fcpu = 32768hz / 4) tc0rate tc0clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fosc/128 8.192 ms 32 us 1000 ms 7812.5 us 001 fosc/64 4.096 ms 16 us 500 ms 3906.25 us 010 fosc/32 2.048 ms 8 us 250 ms 1953.125 us 011 fosc/16 1.024 ms 4 us 125 ms 976.563 us 100 fosc/8 0.512 ms 2 us 62.5 ms 488.281 us 101 fosc/4 0.256 ms 1 us 31.25 ms 244.141 us 110 fosc/2 0.128 ms 0.5 us 15.625 ms 122.07 us 111 fosc/1 0.064 ms 0.25 us 7.813 ms 61.035 us
SN8P2711 8-bit micro-controller sonix technology co., ltd page 85 version 1.4 8.2.5 tc0r auto-load register tc0 timer is with auto-load function controlled by aload0 bit of tc0m. when tc0c overflow occurring, tc0r value will load to tc0c by system. it is easy to generate an ac curate time, and users don?t reset tc0c during interrupt service routine. tc0 is double buffer design. if new tc0r value is set by program, the new value is stored in 1 st buffer. until tc0 overflow occurs, the new value moves to real tc0r buffer. this way can avoid tc0 interval time error and glitch in pwm and buzzer output. ? note: under pwm mode, auto-load is enabled automatically. the aload0 bit is selecting overflow boundary. 0cdh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0r tc0r7 tc0r6 tc0r5 tc0r4 tc0r3 tc0r2 tc0r1 tc0r0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 the equation of tc0r initial value is as following. tc0r initial value = n - (tc0 interrupt interval time * input clock) n is tc0 overflow boundary number. tc0 timer overflow time has six types (tc0 timer, tc0 event counter, tc0 fcpu clock source, tc0 fosc clock source, pwm mode and no pw m mode). these parameters decide tc0 overflow time and valid value as follow table. tc0cks tc0x8 pwm0 aload0 tc0out n tc0r valid value tc0r value binary type 0 x x 256 0x00~0xff 00000000b~11111111b 1 0 0 256 0x00~0xff 00000000b~11111111b 1 0 1 64 0x00~0x3f xx000000b~xx111111b 1 1 0 32 0x00~0x1f xxx00000b~xxx11111b 0 (fcpu/2~ fcpu/256) 1 1 1 16 0x00~0x0f xxxx0000b~xxxx1111b 0 x x 256 0x00~0xff 00000000b~11111111b 1 0 0 256 0x00~0xff 00000000b~11111111b 1 0 1 64 0x00~0x3f xx000000b~xx111111b 1 1 0 32 0x00~0x1f xxx00000b~xxx11111b 0 1 (fosc/1~ fosc/128) 1 1 1 16 0x00~0x0f xxxx0000b~xxxx1111b 1 - - - - 256 0x00~0xff 00000000b~11111111b ? example: to set 10ms interval time for tc0 interr upt. tc0 clock source is fcpu (tc0ks=0, tc0x8=0) and no pwm output (pwm0=0). high clock is external 4mhz . fcpu=fosc/4. select tc0rate=010 (fcpu/64). tc0r initial value = n - (tc0 interrupt interval time * input clock) = 256 - (10ms * 4mhz / 4 / 64) = 256 - (10 -2 * 4 * 10 6 / 4 / 64) = 100 = 64h
SN8P2711 8-bit micro-controller sonix technology co., ltd page 86 version 1.4 8.2.6 tc0 clock freque ncy output (buzzer) buzzer output (tc0out) is from tc0 timer/counter frequen cy output function. by setting the tc0 clock frequency, the clock signal is output to p5.4 and the p5.4 general purpose i/o function is auto-disable. the tc0out frequency is divided by 2 from tc0 interval time. tc0out frequency is 1/2 tc0 frequency. the tc0 clock has many combinations and easily to make difference frequency. the tc0out frequency waveform is as following. 1 2 3 4 1 2 3 4 tc0 overflow clock tc0out (buzzer) output clock ? example: setup tc0out output from tc0 to tc0out (p5.4). the external high-speed clock is 4mhz. the tc0out frequency is 0.5khz. because the tc0out signal is divided by 2, set the tc0 clock to 1khz. the tc0 clock source is from external o scillator clock. t0c rate is fcpu/ 4. the tc0rate2~tc0rate1 = 110. tc0c = tc0r = 131. mov a,#01100000b b0mov tc0m,a ; set the tc0 rate to fcpu/4 mov a,#131 ; set the auto-reload reference value b0mov tc0c,a b0mov tc0r,a b0bset ftc0out ; enable tc0 output to p5.4 and disable p5.4 i/o function b0bset faload1 ; enable tc0 auto-reload function b0bset ftc0enb ; enable tc0 timer ? note: buzzer output is enable, and ?pwm0out? must be ?0?.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 87 version 1.4 8.2.7 tc0 timer operation sequence tc0 timer operation includes timer interrupt, event counter , tc0out and pwm. the sequence of setup tc0 timer is as following. ) stop tc0 timer counting, disable tc0 interrupt function and clear tc0 interrupt request flag. b0bclr ftc0enb ; tc0 timer, tc0out and pwm stop. b0bclr ftc0ien ; tc0 inte rrupt function is disabled. b0bclr ftc0irq ; tc0 interrupt request flag is cleared. ) set tc0 timer rate. (besides event counter mode.) mov a, #0xxx0000b ;the tc0 rate control bi ts exist in bit4~bit6 of tc0m. the ; value is from x000xxxxb~x111xxxxb. b0mov tc0m,a ; tc0 interr upt function is disabled. ) set tc0 timer clock source. ; select tc0 internal / external clock source. b0bclr ftc0cks ; select tc0 internal clock source. or b0bset ftc0cks ; select tc 0 external clock source. ; select tc0 fcpu / fosc internal clock source . b0bclr ftc0x8 ; select tc0 fcpu internal clock source. or b0bset ftc0x8 ; select tc0 fosc internal clock source. ? note: tc0x8 is useless in tc0 external clock source mode. ) set tc0 timer auto-load mode. b0bclr faload0 ; enable tc0 auto reload function. or b0bset faload0 ; disable tc0 auto reload function. ) set tc0 interrupt interval time, tc0out (buzzer) frequency or pwm duty cycle. ; set tc0 interrupt interval time, tc 0out (buzzer) frequency or pwm duty. mov a,#7fh ; tc0c and tc0r value is decided by tc0 mode. b0mov tc0c,a ; set tc0c value. b0mov tc0r,a ; set tc0r value unde r auto reload mode or pwm mode. ; in pwm mode, set pwm cycle. b0bclr faload0 ; aload0, tc0out = 00, pwm cycle boundary is b0bclr ftc0out ; 0~255. or b0bclr faload0 ; aload0, tc0out = 01, pwm cycle boundary is b0bset ftc0out ; 0~63. or b0bset faload0 ; aload0, tc0out = 10, pwm cycle boundary is b0bclr ftc0out ; 0~31. or b0bset faload0 ; aload0, tc0out = 11, pwm cycle boundary is b0bset ftc0out ; 0~15.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 88 version 1.4 ) set tc0 timer function mode. b0bset ftc0ien ; enable tc0 interrupt function. or b0bset ftc0out ; enable tc 0out (buzzer) function. or b0bset fpwm0out ; enable pwm function. or b0bset ftc0gn ; enable tc0 gre en mode wake-up function. ) enable tc0 timer. b0bset ftc0enb ; enable tc0 timer.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 89 version 1.4
SN8P2711 8-bit micro-controller sonix technology co., ltd page 90 version 1.4 8.3 timer/counter 1 (tc1) 8.3.1 overview the tc1 is an 8-bit binary up counting timer with double buffers. tc1 has two clock sources including internal clock and external clock for counting a precision time. the internal clock source is from fcpu or fosc controlled by tc1x8 flag to get faster clock source (fosc). the external clock is int1 from p0.1 pin (falling edge trigger). using tc1m register selects tc1c?s clock source from internal or external. if tc1 timer occurs an overflow, it will continue counting and issue a time-out signal to trigger tc1 interrupt to requ est interrupt service. tc1 overflow time is 0xff to 0x00 normally. under pwm mode, tc1 overflow is decided by pwm cycle controlled by aload1 and tc1out bits. the main purposes of the tc1 timer is as following. ) 8-bit programmable up counting timer: generates interrupts at specific time intervals based on the selected clock frequency. ) external event counter: counts system ?events? based on falling edge detection of external clock signals at the int1 input pin. ) buzzer output ) pwm output fcpu tc1 rate (fcpu/2~fcpu/256) fosc tc1 rate (fosc/1~fosc/128) tc1x8 int1 (schmitter trigger) tc1cks tc1enb cpum0,1 tc1c 8-bit binary up counting counter tc1r reload data buffer up counting reload value tc1 time out compare aload1 r s tc1 time out auto. reload tc1 / 2 buzzer internal p5.3 i/o circuit p5.3 pwm pwm1out tc1out aload1, tc1out load
SN8P2711 8-bit micro-controller sonix technology co., ltd page 91 version 1.4 8.3.2 tc1m mode register 0dch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1m tc1enb tc1rate2 tc1rate1 tc1rate0 tc1cks aload1 tc1out pwm1out read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 0 pwm1out: pwm output control bit. 0 = disable pwm output. 1 = enable pwm output. pwm duty controlled by tc1out, aload1 bits. bit 1 tc1out: tc1 time out toggle signal output control bit. only valid when pwm1out = 0. 0 = disable, p5.3 is i/o function. 1 = enable, p5.3 is output tc1out signal. bit 2 aload1: auto-reload control bit. only valid when pwm1out = 0. 0 = disable tc1 auto-reload function. 1 = enable tc1 auto-reload function. bit 3 tc1cks: tc1 clock source select bit. 0 = internal clock (fcpu or fosc). 1 = external clock from p0.1/int1 pin. bit [6:4] tc1rate[2:0]: tc1 internal clock select bits. tc1rate [2:0] tc1x8 = 0 tc1x8 = 1 000 fcpu / 256 fosc / 128 001 fcpu / 128 fosc / 64 010 fcpu / 64 fosc / 32 011 fcpu / 32 fosc / 16 100 fcpu / 16 fosc / 8 101 fcpu / 8 fosc / 4 110 fcpu / 4 fosc / 2 111 fcpu / 2 fosc / 1 bit 7 tc1enb: tc1 counter control bit. 0 = disable tc1 timer. 1 = enable tc1 timer. ? note: when tc1cks=1, tc1 became an external event counter and tc1rate is useless. no more p0.1 interrupt request will be raised. (p0.1irq will be always 0). 8.3.3 tc1x8 flag 0d8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0m - - - - tc1x8 - - - read/write - - - - r/w - - - after reset - - - - 0 - - - bit 3 tc1x8: tc1 internal clock source control bit. 0 = tc1 internal clock source is fcpu. tc1rate is from fcpu/2~fcpu/256. 1 = tc1 internal clock source is fo sc. tc1rate is from fosc/1~fosc/128. ? note: under tc1 event counter mode (tc1ck s=1), tc1x8 bit and tc1rate are useless.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 92 version 1.4 8.3.4 tc1c counting register tc1c is an 8-bit counter register for tc1 interval time control. 0ddh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1c tc1c7 tc1c6 tc1c5 tc1c4 tc1c3 tc1c2 tc1c1 tc1c0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of tc1c initial value is as following. tc1c initial value = n - (tc1 interrupt interval time * input clock) n is tc1 overflow boundary number. tc1 timer overflow time has six types (tc1 timer, tc1 event counter, tc1 fcpu clock source, tc1 fosc clock source, pwm mode and no pw m mode). these parameters decide tc1 overflow time and valid value as follow table. tc1cks tc1x8 pwm1 aload1 tc1out n tc1c valid value tc1c value binary type remark 0 x x 256 0x00~0xff 00000000b~11111111b overflow per 256 count 1 0 0 256 0x00~0xff 00000000b~11111111b overflow per 256 count 1 0 1 64 0x00~0x3f xx000000b~xx111111b overflow per 64 count 1 1 0 32 0x00~0x1f xxx00000b~xxx11111b overflow per 32 count 0 (fcpu/2~ fcpu/256) 1 1 1 16 0x00~0x0f xxxx0000b~xxxx1111b overflow per 16 count 0 x x 256 0x00~0xff 00000000b~11111111b overflow per 256 count 1 0 0 256 0x00~0xff 00000000b~11111111b overflow per 256 count 1 0 1 64 0x00~0x3f xx000000b~xx111111b overflow per 64 count 1 1 0 32 0x00~0x1f xxx00000b~xxx11111b overflow per 32 count 0 1 (fosc/1~ fosc/128) 1 1 1 16 0x00~0x0f xxxx0000b~xxxx1111b overflow per 16 count 1 - - - - 256 0x00~0xff 00000000b~11111111b overflow per 256 count ? example: to set 10ms interval time for tc1 interr upt. tc1 clock source is fcpu (tc1ks=0, tc1x8=0) and no pwm output (pwm1=0). high clock is external 4mhz . fcpu=fosc/4. select tc1rate=010 (fcpu/64). tc1c initial value = n - (tc1 interrupt interval time * input clock) = 256 - (10ms * 4mhz / 4 / 64) = 256 - (10 -2 * 4 * 10 6 / 4 / 64) = 100 = 64h
SN8P2711 8-bit micro-controller sonix technology co., ltd page 93 version 1.4 the basic timer table interval time of tc1, tc1x8 = 0. high speed mode (fcpu = 4mhz / 4) low speed mode (fcpu = 32768hz / 4) tc1rate tc1clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fcpu/256 65.536 ms 256 us 8000 ms 31250 us 001 fcpu/128 32.768 ms 128 us 4000 ms 15625 us 010 fcpu/64 16.384 ms 64 us 2000 ms 7812.5 us 011 fcpu/32 8.192 ms 32 us 1000 ms 3906.25 us 100 fcpu/16 4.096 ms 16 us 500 ms 1953.125 us 101 fcpu/8 2.048 ms 8 us 250 ms 976.563 us 110 fcpu/4 1.024 ms 4 us 125 ms 488.281 us 111 fcpu/2 0.512 ms 2 us 62.5 ms 244.141 us the basic timer table interval time of tc1, tc1x8 = 1. high speed mode (fcpu = 4mhz / 4) low speed mode (fcpu = 32768hz / 4) tc1rate tc1clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fosc/128 8.192 ms 32 us 1000 ms 7812.5 us 001 fosc/64 4.096 ms 16 us 500 ms 3906.25 us 010 fosc/32 2.048 ms 8 us 250 ms 1953.125 us 011 fosc/16 1.024 ms 4 us 125 ms 976.563 us 100 fosc/8 0.512 ms 2 us 62.5 ms 488.281 us 101 fosc/4 0.256 ms 1 us 31.25 ms 244.141 us 110 fosc/2 0.128 ms 0.5 us 15.625 ms 122.07 us 111 fosc/1 0.064 ms 0.25 us 7.813 ms 61.035 us
SN8P2711 8-bit micro-controller sonix technology co., ltd page 94 version 1.4 8.3.5 tc1r auto-load register tc1 timer is with auto-load function controlled by aload1 bit of tc1m. when tc1c overflow occurring, tc1r value will load to tc1c by system. it is easy to generate an ac curate time, and users don?t reset tc1c during interrupt service routine. tc1 is double buffer design. if new tc1r value is set by program, the new value is stored in 1 st buffer. until tc1 overflow occurs, the new value moves to real tc1r buffer. this way can avoid tc1 interval time error and glitch in pwm and buzzer output. ? note: under pwm mode, auto-load is enabled automatically. the aload1 bit is selecting overflow boundary. 0deh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1r tc1r7 tc1r6 tc1r5 tc1r4 tc1r3 tc1r2 tc1r1 tc1r0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 the equation of tc1r initial value is as following. tc1r initial value = n - (tc1 interrupt interval time * input clock) n is tc1 overflow boundary number. tc1 timer overflow time has six types (tc1 timer, tc1 event counter, tc1 fcpu clock source, tc1 fosc clock source, pwm mode and no pw m mode). these parameters decide tc1 overflow time and valid value as follow table. tc1cks tc1x8 pwm1 aload1 tc1out n tc1r valid value tc1r value binary type 0 x x 256 0x00~0xff 00000000b~11111111b 1 0 0 256 0x00~0xff 00000000b~11111111b 1 0 1 64 0x00~0x3f xx000000b~xx111111b 1 1 0 32 0x00~0x1f xxx00000b~xxx11111b 0 (fcpu/2~ fcpu/256) 1 1 1 16 0x00~0x0f xxxx0000b~xxxx1111b 0 x x 256 0x00~0xff 00000000b~11111111b 1 0 0 256 0x00~0xff 00000000b~11111111b 1 0 1 64 0x00~0x3f xx000000b~xx111111b 1 1 0 32 0x00~0x1f xxx00000b~xxx11111b 0 1 (fosc/1~ fosc/128) 1 1 1 16 0x00~0x0f xxxx0000b~xxxx1111b 1 - - - - 256 0x00~0xff 00000000b~11111111b ? example: to set 10ms interval time for tc1 interr upt. tc1 clock source is fcpu (tc1ks=0, tc1x8=0) and no pwm output (pwm1=0). high clock is external 4mhz . fcpu=fosc/4. select tc1rate=010 (fcpu/64). tc1r initial value = n - (tc1 interrupt interval time * input clock) = 256 - (10ms * 4mhz / 4 / 64) = 256 - (10 -2 * 4 * 10 6 / 4 / 64) = 100 = 64h
SN8P2711 8-bit micro-controller sonix technology co., ltd page 95 version 1.4 8.3.6 tc1 clock freque ncy output (buzzer) buzzer output (tc1out) is from tc1 timer/counter frequen cy output function. by setting the tc1 clock frequency, the clock signal is output to p5.3 and the p5.3 general purpose i/o function is auto-disable. the tc1out frequency is divided by 2 from tc1 interval time. tc1out frequency is 1/2 tc1 frequency. the tc1 clock has many combinations and easily to make difference frequency. the tc1out frequency waveform is as following. 1 2 3 4 1 2 3 4 tc1 overflow clock tc1out (buzzer) output clock ? example: setup tc1out output from tc1 to tc1out (p5.3). the external high-speed clock is 4mhz. the tc1out frequency is 0.5khz. because the tc1out signal is divided by 2, set the tc1 clock to 1khz. the tc1 clock source is from external o scillator clock. tc1 rate is fcpu/ 4. the tc1rate2~tc1rate1 = 110. tc1c = tc1r = 131. mov a,#01100000b b0mov tc1m,a ; set the tc1 rate to fcpu/4 mov a,#131 ; set the auto-reload reference value b0mov tc1c,a b0mov tc1r,a b0bset ftc1out ; enable tc1 output to p5.3 and disable p5.3 i/o function b0bset faload1 ; enable tc1 auto-reload function b0bset ftc1enb ; enable tc1 timer ? note: buzzer output is enable, and ?pwm1out? must be ?0?.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 96 version 1.4 8.3.7 tc1 timer operation sequence tc1 timer operation includes timer interrupt, event counter , tc1out and pwm. the sequence of setup tc1 timer is as following. ) stop tc1 timer counting, disable tc1 interrupt function and clear tc1 interrupt request flag. b0bclr ftc1enb ; tc1 timer, tc1out and pwm stop. b0bclr ftc1ien ; tc1 inte rrupt function is disabled. b0bclr ftc1irq ; tc1 interrupt request flag is cleared. ) set tc1 timer rate. (besides event counter mode.) mov a, #0xxx0000b ;the tc1 rate control bi ts exist in bit4~bit6 of tc1m. the ; value is from x000xxxxb~x111xxxxb. b0mov tc1m,a ; tc1 timer is disabled. ) set tc1 timer clock source. ; select tc1 internal / external clock source. b0bclr ftc1cks ; select tc1 internal clock source. or b0bset ftc1cks ; select tc 1 external clock source. ; select tc1 fcpu / fosc internal clock source . b0bclr ftc1x8 ; select tc1 fcpu internal clock source. or b0bset ftc1x8 ; select tc1 fosc internal clock source. ? note: tc1x8 is useless in tc1 external clock source mode. ) set tc1 timer auto-load mode. b0bclr faload1 ; enable tc1 auto reload function. or b0bset faload1 ; disable tc1 auto reload function. ) set tc1 interrupt interval time, tc1out (buzzer) frequency or pwm duty cycle. ; set tc1 interrupt interval time, tc 1out (buzzer) frequency or pwm duty. mov a,#7fh ; tc1c and tc1r value is decided by tc1 mode. b0mov tc1c,a ; set tc1c value. b0mov tc1r,a ; set tc1r value unde r auto reload mode or pwm mode. ; in pwm mode, set pwm cycle. b0bclr faload1 ; aload1, tc1out = 00, pwm cycle boundary is 0~255. b0bclr ftc1out or b0bclr faload1 ; aload1, tc1out = 01, pwm cycle boundary is 0~63. b0bset ftc1out or b0bset faload1 ; aload1, tc1out = 10, pwm cycle boundary is 0~31. b0bclr ftc1out or b0bset faload1 ; aload1, tc1out = 11, pwm cycle boundary is 0~15. b0bset ftc1out
SN8P2711 8-bit micro-controller sonix technology co., ltd page 97 version 1.4 ) set tc1 timer function mode. b0bset ftc1ien ; enable tc1 interrupt function. or b0bset ftc1out ; enable tc 1out (buzzer) function. or b0bset fpwm1out ; enable pwm function. ) enable tc1 timer. b0bset ftc1enb ; enable tc1 timer.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 98 version 1.4 8.4 pwm mode 8.4.1 overview pwm function is generated by tcn timer counter and output the pwm signal to pwmnout pin (p5.3/p5.4). the 8-bit counter counts modulus 256, 64, 32, 16 controlled by aloadn, tcnout bits. the value of the 8-bit counter (tcnc) is compared to the contents of the referenc e register (tcnr). when the reference register value (tcnr) is equal to the counter value (tcnc), the pwm output goes low. when the co unter reaches zero, the pwm output is forced high. the low-to-high ratio (duty) of the pw mn output is tcnr/256, 64, 32, 16. pwm output can be held at low level by continuously loading the reference register with 00h. under pwm operating, to change the pwm?s duty cycle is to modify the tcnr. ? note: the ?n? of tcn,tcnc? is 0 or 1 follow timer mode. ?n=0? is tc0 mode. ?n=1? is tc1 mode. ? note: tcn is double buffer design. modifying tcnr to change pwm duty by program, there is no glitch and error duty signal in pwm output waveform. users can change tcnr any time, and the new reload value is loaded to tcnr buffer at tcn overflow. aloadn tcnout pwm duty range tcnc valid value tcnr valid bits value max. pwm frequency (fcpu = 4mhz) remark 0 0 0/256~255/256 0x00~0xff 0x00~0xff 7.8125k overflow per 256 count 0 1 0/64~63/64 0x00~0x3f 0x00~0x3f 31.25k overflow per 64 count 1 0 0/32~31/32 0x00~0x1f 0x00~0x1f 62.5k overflow per 32 count 1 1 0/16~15/16 0x00~0x0f 0x00~0x0f 125k overflow per 16 count the output duty of pwm is with different tcnr. duty range is from 0/256~255/256. tcn clock tcnr=00h tcnr=01h tcnr=80h tcnr=ffh 0 1 128 254 255 0 1 128 254 255 low low low high high low high
SN8P2711 8-bit micro-controller sonix technology co., ltd page 99 version 1.4 8.4.2 tcnirq and pwm duty in pwm mode, the frequency of tcnirq is depended on pwm duty range. from following diagram, the tcnirq frequency is related with pwm duty. tcn overflow, tcnirq = 1 pwmn output (duty range 0~15) 0xff tcnc value 0x00 pwmn output (duty range 0~31) 0xff tcnc value 0x00 pwmn output (duty range 0~63) 0xff tcnc value 0x00 0xff tcnc value 0x00 pwmn output (duty range 0~255) tcn overflow, tcnirq = 1 tcn overflow, tcnirq = 1 tcn overflow, tcnirq = 1
SN8P2711 8-bit micro-controller sonix technology co., ltd page 100 version 1.4 8.4.3 pwm duty with tcnr changing in pwm mode, the system will compare tcnc and tcnr all the time. when tcnc = tcnr pwm high > low tcnc < tcnr pwm low > high in period 2 and period 4, new duty (tcnr) is set. tcn is double buffer de sign. the pwm still keeps the same duty in period 2 and period 4, and the new duty is changed in ne xt period. by the way, sy stem can avoid the pwm not changing or h/l changing twice in the same cycle an d will prevent the unexpected or error operation.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 101 version 1.4 8.4.4 pwm program example ? example: setup pwm0 output from tc0 to pwm0out (p5.4). the extern al high-speed oscillator clock is 4mhz. fcpu = fosc/4. the duty of pwm is 30/256. the pwm frequency is about 1khz. the pwm clock source is from external oscillator clock. tc0 rate is fcpu/4. the tc0rate2~tc0rate1 = 110. tc0c = tc0r = 30. mov a,#01100000b b0mov tc0m,a ; set the tc0 rate to fcpu/4 mov a,#30 ; set the pwm duty to 30/256 b0mov tc0c,a b0mov tc0r,a b0bclr ftc0out ; set duty range as 0/256~255/256. b0bclr faload0 b0bset fpwm0out ; enable pwm0 output to p5.4 and disable p5.4 i/o function b0bset ftc0enb ; enable tc0 timer ? note: the tcnr is write-only register. don?t pr ocess them using incms, decms instructions. ? example: modify tc0r registers? value. mov a, #30h ; input a number using b0mov instruction. b0mov tc0r, a incms buf0 ; get the new tc0r value from the buf0 buffer defined by nop ; programming. b0mov a, buf0 b0mov tc0r, a ? note: the pwm can work with interrupt request.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 102 version 1.4 9 9 9 5+1 channel analog to digital converter 9.1 overview this analog to digital converter has 5 external sources (ain 0~ain4) and one internal source (ain5: internal 1/4 vdd) with 4096-step resolution to transfer analog signal into 12-bits digital data. the sequence of adc operation is to select input source (ain0 ~ ain5) at first, then set gchs and ads bit to ?1? to start conversion. when the conversion is complete, the adc circuit will set eoc bit to ?1? and final 12-bits value output in adb and adr low-nibble registers. ain0/p4.0 ain1/p4.1 ain2/p4.2 ain3/p4.3 ain4/p4.4 ain5 (internal 1/4 vdd) a/d converter (adc) data bus 12-bits
SN8P2711 8-bit micro-controller sonix technology co., ltd page 103 version 1.4 9.2 adm register 0b1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adm adenb ads eoc gchs - chs2 chs1 chs0 read/write r/w r/w r/ w r/w - r/w r/w r/w after reset 0 0 0 0 - 0 0 0 bit 7 adenb: adc control bit. 0 = disable. 1 = enable. bit 6 ads: adc start bit. 0 = stop. 1 = starting. bit 5 eoc: adc status bit. 0 = progressing. 1 = end of converting and reset ads bit. bit 4 gchs: global channel select bit. 0 = disable ain channel. 1 = enable ain channel. bit[2:0] chs[2:0]: adc input channels select bit. 000 = ain0, 001 = ain1, 010 = ain2, 011 = ain3, 100 = ain4, 101 = ain5. the ain5 is internal 1/4 vdd input channel. there is no any input pin from outside. ain5 can be a good battery detector for battery system. to select appropriate intern al vrefh level and compare value, a high performance and cheaper low battery detector is built in the system. ? note: if adenb = 1, users should set p4.n/ainn as input mode without pull-up. system doesn?t set automatically. if p4con.n is set, the p4.n/ainn?s di gital i/o function including pull-up is isolated.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 104 version 1.4 9.3 adr registers 0b3h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adr - adcks1 - adcks0 adb3 adb2 adb1 adb0 read/write - r/w - r/w r r r r after reset - 0 - 0 - - - - bit[6,4] adcks1, adcks0: adc clock source selection. adcks1 adcks0 adc clock source 0 0 fcpu/16 0 1 fcpu/8 1 0 fcpu 1 1 fcpu/2 bit[3:0] adb[3:0]: adc low-nibble data buffer of 12-bit adc resolution. ? note: adc buffer adr [3:0] initial value after reset is unknown.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 105 version 1.4 9.4 adb registers 0b2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adb adb15 adb14 adb13 adb12 adb11 adb10 adb9 adb8 read/write r r r r r r r r after reset - - - - - - - - bit[7:0] adb[7:0]: adc high-byte data buffer of 12-bit adc resolution. adb is adc data buffer to store ad converter result. the adb is only 8-bit register including bit 4~bit11 adc data. to combine adb register and the low-nibble of adr will get full 12-bit adc data buffer. the adc buffer is a read-only register. in 8-bit adc mode, the adc data is stored in adb register. in 12-bit adc mode, the adc data is stored in adb and adr registers. the ain?s input voltage v.s. adb?s output data ain n adb1 1 adb10 adb9 adb8 adb7 adb6 ad b5 adb4 adb3 ad b2 adb1 adb0 0/4096*vrefh 0 0 0 0 0 0 0 0 0 0 0 0 1/4096*vrefh 0 0 0 0 0 0 0 0 0 0 0 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4094/4096*vrefh 1 1 1 1 1 1 1 1 1 1 1 0 4095/4096*vrefh 1 1 1 1 1 1 1 1 1 1 1 1 for different applications, users maybe need more than 8-bit resolution but less than 12-bit adc converter. to process the adb and adr data can make the job well. first, the ad resolution must be set 12-bit mode and then to execute adc converter routine. then delete the lsb of adc data and get the new resolution result. the table is as following. adb adr adc resolution adb11 adb10 adb9 adb8 adb7 adb6 adb5 adb4 adb3 adb2 adb1 adb0 8-bit o o o o o o o o x x x x 9-bit o o o o o o o o o x x x 10-bit o o o o o o o o o o x x 11-bit o o o o o o o o o o o x 12-bit o o o o o o o o o o o o o = selected, x = delete ? note: adc buffer adb initial value after reset is unknown.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 106 version 1.4 9.5 p4con registers the port 4 is shared with adc input function. only one pi n of port 4 can be configured as adc input in the same time by adm register. the other pins of port 4 are digital i/o pins. connect an analog signal to coms digital input pin, especially the analog signal level is about 1/2 vdd will ca use extra current leakage. in the power down mode, the above leakage current will be a big problem. unfortunately, if users connect more than one analog input signal to port 4 will encounter above current leakage situation. p4con is port 4 configuration register. write ?1? into p4con [7:0] will configure related port 4 pin as pure anal og input pin to avoid current leakage. 0aeh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4con - - - p4con4 p4con3 p4con2 p4con1 p4con0 read/write - - - r/w r/w r/w r/w r/w after reset - - - 0 0 0 0 0 bit[4:0] p4con[4:0]: p4.n configuration control bits. 0 = p4.n can be an analog input (adc input) or digital i/o pins. 1 = p4.n is pure analog input, can?t be a digital i/o pin. ? note: when port 4.n is general i/o port not adc channel, p4con.n must set to ?0? or the port 4.n digital i/o signal would be isolated.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 107 version 1.4 9.6 vrefh registers the port 4 is shared with adc input function. only one pi n of port 4 can be configured as adc input in the same time by adm register. the other pins of port 4 are digital i/o pins. connect an analog signal to cmos digital input pin, especially the analog signal level is about 1/2 vdd will ca use extra current leakage. in the power down mode, the above leakage current will be a big problem. unfortunately, if users connect more than one analog input signal to port 4 will encounter above current leakage situation. p4con is port 4 configuration register. write ?1? into p4con [7:0] will configure related port 4 pin as pure anal og input pin to avoid current leakage. ? note: a. adc resolution is 8-bit if use internal 4v/3v/2v reference voltage. b. adc resolution is 12-bit if use internal vdd reference voltage or use external reference voltage. 0afh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 vrefh evhenb - - - - - vhs1 vhs0 read/write r/w - - - - - r/w r/w after reset 0 - - - - - 0 0 bit[1:0] vhs[1:0]: adc internal reference high voltage select bits. vhs1 vhs0 internal vrefh voltage 1 1 vdd 1 0 4.0v 0 1 3.0v 0 0 2.0v ? note: if internal vrefh level selected by vhs[1:0] is higher than vdd, the internal vrefh is vdd. for instance, vhs[1:0] is 10 (internal vrefh = 4.0v) and vdd is 3.0v, the actual internal vrefh is equal to vdd (3.0v). bit[7] evhenb: adc internal reference high voltage control bit. 0 = enable adc internal vrefh function, p4.0/ain0/vrefh pin is p4.0/ain0 pin. 1 = disable adc internal vrefh function, p4.0/a in0/vrefh pin is external vrefh input pin. ? note: if evhenb = 1, p4.0/ain0 pi n is external vrefh input pin and p4.0 i/o and ain0 functions are isolated.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 108 version 1.4 9.7 adc converting time 12-bit adc conversion time = 1/(adc clock /4)*16 sec high clock (fosc) = 4mhz fcpu adcks1 adcks0 adc clock adc converting time 0 0 fcpu/16 1/( ( 4mhz / 1 ) / 16 /4 ) x16= 256 us 0 1 fcpu/8 1/( ( 4mhz / 1 ) / 8 /4 ) x16= 128 us 1 0 fcpu 1/( ( 4mhz / 1 ) / 1 /4 ) x16= 16 us fosc/ 1 1 1 fcpu/2 1/( ( 4mhz / 1 ) / 2 /4 ) x16= 32 us 0 0 fcpu/16 1/( ( 4mhz / 2 ) / 16 /4 ) x16= 512 us 0 1 fcpu/8 1/( ( 4mhz / 2 ) / 8 /4 ) x16= 256 us 1 0 fcpu 1/( ( 4mhz / 2 ) / 1 /4 ) x16= 32 us fosc/ 2 1 1 fcpu/2 1/( ( 4mhz / 2 ) / 2 /4 ) x16= 64 us 0 0 fcpu/16 1/( ( 4mhz / 4 ) / 16 /4 ) x16= 1024 us 0 1 fcpu/8 1/( ( 4mhz / 4 ) / 8 /4 ) x16= 512 us 1 0 fcpu 1/( ( 4mhz / 4 ) / 1 /4 ) x16= 64 us fosc/ 4 1 1 fcpu/2 1/( ( 4mhz / 4 ) / 2 /4 ) x16= 128 us 0 0 fcpu/16 1/( ( 4mhz / 8 ) / 16 /4 ) x16= 2048 us 0 1 fcpu/8 1/( ( 4mhz / 8 ) / 8 /4 ) x16= 1024 us 1 0 fcpu 1/( ( 4mhz / 8 ) / 1 /4 ) x16= 128 us fosc/ 8 1 1 fcpu/2 1/( ( 4mhz / 8 ) / 2 /4 ) x16= 256 us 0 0 fcpu/16 1/( ( 4mhz / 16 ) / 16 /4 ) x16= 4096 us 0 1 fcpu/8 1/( ( 4mhz / 16 ) / 8 /4 ) x16= 2048 us 1 0 fcpu 1/( ( 4mhz / 16 ) / 1 /4 ) x16= 256 us fosc/ 16 1 1 fcpu/2 1/( ( 4mhz / 16 ) / 2 /4 ) x16= 512 us
SN8P2711 8-bit micro-controller sonix technology co., ltd page 109 version 1.4 9.8 adc routine example ? example : to set ain0 for adc input and executing 12-bi t adc. vrefh is internal 3.0v. adc clock source is fcpu. ; enable adc function and delay 100us for conversion. adc0: b0bset fadenb ; enable adc circuit call delay100us ; delay 100us to wait adc circuit ready for conversion. ; set port 4 i/o mode. mov a, #0feh b0mov p4ur, a ; disable p4.0 pull-up resistor. b0bclr fp40m ; set p4.0 as input pin. ; or mov a, #01h b0mov p4con, a ; set p4.0 as pure analog input. ; set vrefh is internal 3.0v. mov a, #01h b0mov vrefh, a ; set internal 3.0v vrefh. ; set adc clock source = fcpu. mov a, #40h b0mov adr, a ; to set adc clock = fcpu. ; enable ain0 (p4.0). mov a, #90h b0mov adm, a ; to enable adc and set ain0 input ; start ad conversion. b0bset fads ; to start conversion wadc0: b0bts1 feoc ; to skip, if end of converting =1 jmp wadc0 ; else, jump to wadc0 b0mov a, adb ; to get ain0 input data bit11 ~ bit4 b0mov adc_buf_hi, a b0mov a, adr ; to get ain0 input data bit3 ~ bit0 and a, 0fh b0mov adc_buf_low, a end_adc: . b0bclr fadenb ; disable adc circuit
SN8P2711 8-bit micro-controller sonix technology co., ltd page 110 version 1.4 ? example : to set ain1 for adc input and executing 12- bit adc. vrefh is external input voltage from vrefh pin (p4.0/ain0). adc clock s ource is fcpu. using adc interrupt. ; enable adc function and delay 100us for conversion. adc0: b0bset fadenb ; enable adc circuit call delay100us ; delay 100us to wait adc circuit ready for conversion. ; set port 4 i/o mode. mov a, #0fdh b0mov p4ur, a ; disable p4.1 pull-up resistor. b0bclr fp41m ; set p4.1 as input pin. ; or mov a, #02h b0mov p4con, a ; set p4.1 as pure analog input. ; set vrefh is external input voltage. b0bset evhenb ; enable external vrefh input. ; set adc clock source = fcpu. mov a, #40h b0mov adr, a ; to set adc clock = fcpu. ; enable ain0 (p4.1). mov a, #91h b0mov adm,a ; to enable adc and set ain1 input ; set adc interrupt. b0bclr fadcirq ; clear adc interrupt request flag. b0bset fadcien ; enable adc interrupt function. b0bset fgie ; enable global interrupt function. ; start ad conversion. b0bset fads ; to start conversion ? ? ? adc_int_sr: push b0bts1 fadcirq ; check adc interrupt flag. jmp adc_int_exit b0bclr fadcirq ; clear adc interrupt request flag. b0mov a, adb ; to get ain0 input data bit11 ~ bit4 b0mov adc_buf_hi, a b0mov a, adr ; to get ain0 input data bit3 ~ bit0 and a, 0fh b0mov adc_buf_low, a b0bclr fadenb ; disable adc circuit adc_int_exit: . pop reti
SN8P2711 8-bit micro-controller sonix technology co., ltd page 111 version 1.4 9.9 adc circuit mcu vcc gnd ainn/p4.n v d d vss 0.1uf analog signal input 47uf 0.1uf adc reference high voltage is internal reference voltage a nd vrefh pin is ain0/p4.0. the capacitor (0.1uf) between ainn/p4.n and vss is necessa ry to stable analog signal. mcu vcc gnd v r e f h ainn/p4.n v d d vss 0.1uf analog signal input 47uf 0.1uf adc reference high voltage is from vdd pin and ain0/p4.0 is verfh input. the verfh should be from mcu?s vdd pin. don?t connect from main power. mcu vcc gnd vrefh ainn/p4.n vdd vss 0.1uf analog signal input 0.1uf 47uf reference high voltage input adc reference high voltage is from external voltage and ain0/p4.0 is verfh input. the capacitor (47uf) between vrefh and vss is necessary to stable verfh voltage.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 112 version 1.4 1 1 1 0 0 0 instruction table field mnemonic description c dc z cycle mov a,m a m - - 1 m mov m,a m a - - - 1 o b0mov a,m a m (bank 0) - - 1 v b0mov m,a m (bank 0) a - - - 1 e mov a,i a i - - - 1 b0mov m,i m i, ?m? only supports 0x80~0x87 registers (e.g. pflag,r,y,z?) - - - 1 xch a,m a m - - - 1+n b0xch a,m a m (bank 0) - - - 1+n movc r, a rom [y,z] - - - 2 adc a,m a a + m + c, if occur carry, then c=1, else c=0 1 a adc m,a m a + m + c, if occur carry, then c=1, else c=0 1+n r add a,m a a + m, if occur carry, then c=1, else c=0 1 i add m,a m a + m, if occur carry, then c=1, else c=0 1+n t b0add m,a m (bank 0) m (bank 0) + a, if occur carry, then c=1, else c=0 1+n h add a,i a a + i, if occur carry, then c=1, else c=0 1 m sbc a,m a a - m - /c, if occur borrow, then c=0, else c=1 1 e sbc m,a m a - m - /c, if occur borrow, then c=0, else c=1 1+n t sub a,m a a - m, if occur borrow, then c=0, else c=1 1 i sub m,a m a - m, if occur borrow, then c=0, else c=1 1+n c sub a,i a a - i, if occur borrow, then c=0, else c=1 1 and a,m a a and m - - 1 l and m,a m a and m - - 1+n o and a,i a a and i - - 1 g or a,m a a or m - - 1 i or m,a m a or m - - 1+n c or a,i a a or i - - 1 xor a,m a a xor m - - 1 xor m,a m a xor m - - 1+n xor a,i a a xor i - - 1 swap m a (b3~b0, b7~b4) m(b7~b4, b3~b0) - - - 1 p swapm m m(b3~b0, b7~b4) m(b7~b4, b3~b0) - - - 1+n r rrc m a rrc m -- 1 o rrcm m m rrc m -- 1+n c rlc m a rlc m -- 1 e rlcm m m rlc m -- 1+n s clr m m 0 - - - 1 s bclr m.b m.b 0 - - - 1+n bset m.b m.b 1 - - - 1+n b0bclr m.b m(bank 0).b 0 - - - 1+n b0bset m.b m(bank 0).b 1 - - - 1+n cmprs a,i zf,c a - i, if a = i, then skip next instruction - 1 + s b cmprs a,m zf,c a ? m, if a = m, then skip next instruction - 1 + s r incs m a m + 1, if a = 0, then skip next instruction - - - 1+ s a incms m m m + 1, if m = 0, then skip next instruction - - - 1+n+s n decs m a m - 1, if a = 0, then skip next instruction - - - 1+ s c decms m m m - 1, if m = 0, then skip next instruction - - - 1+n+s h bts0 m.b if m.b = 0, then skip next instruction - - - 1 + s bts1 m.b if m.b = 1, then skip next instruction - - - 1 + s b0bts0 m.b if m(bank 0).b = 0, then skip next instruction - - - 1 + s b0bts1 m.b if m(bank 0).b = 1, then skip next instruction - - - 1 + s jmp d pc15/14 rompages1/0, pc13~pc0 d - - - 2 call d stack pc15~pc0, pc15/14 rompages1/0, pc13~pc0 d - - - 2 m ret pc stack - - - 2 i reti pc stack, and to enable global interrupt - - - 2 s push to push acc and pflag (except nt0, npd bit) into buffers. - - - 1 c pop to pop acc and pflag (except nt0, npd bit) from buffers. 1 nop no operation - - - 1 note: 1. ?m? is system register or ram. if ?m? is system registers then ?n? = 0, otherwise ?n? = 1. 2. if branch condition is true then ?s = 1?, otherwise ?s = 0?.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 113 version 1.4 1 1 1 1 1 1 electrical characteristic 11.1 absolute maximum rating supply voltage (vdd)????????????????????????????????????????????.?????? - 0.3v ~ 6.0v input in voltage (vin)????????????????????????????????????????????.? vss ? 0.2v ~ vdd + 0.2v operating ambient temperature (topr) SN8P2711p, SN8P2711s, SN8P2711x ?????????????????????????????????????.. 0 c ~ + 70 c SN8P2711pd, SN8P2711sd, SN8P2711xd ?? ?????????????????????????????????. ?40 c ~ + 85 c storage ambient temperature (tstor) ?????????????????????????.???????????????? ?40 c ~ + 125 c 11.2 electrical characteristic (all of voltages refer to vss, vdd = 5.0v, fosc = 4mhz,fcpu=1mhz,ambient temperature is 25 c unless otherwise note.) parameter sym. description min. typ. max. unit normal mode, vpp = vdd, 25 c 2.4 5.0 5.5 v operating voltage vdd normal mode, vpp = vdd, -40 c~85 c 2.5 5.0 5.5 v ram data retention voltage vdr 1.5 - - v vdd rise rate vpor vdd rise rate to ensure internal power-on reset 0.05 - - v/ms vil1 all input ports vss - 0.3vdd v input low voltage vil2 reset pin vss - 0.2vdd v vih1 all input ports 0.7vdd - vdd v input high voltage vih2 reset pin 0.9vdd - vdd v reset pin leakage current il ekg vin = vdd - - 2 ua vin = vss , vdd = 3v 100 200 300 i/o port pull-up resistor rup vin = vss , vdd = 5v 50 100 150 k ? i/o port input leakage current ilekg pull-up resistor disable, vin = vdd - - 2 ua i/o output source current ioh vop = vdd ? 0.5v 8 12 - sink current iol vop = vss + 0.5v 8 15 - ma intn trigger pulse width tint0 int0 inte rrupt request pulse width 2/fcpu - - cycle vdd= 5v, 4mhz - 2.5 5 ma idd1 run mode (no loading, fcpu = fosc/4) vdd= 3v, 4mhz - 1 2 ma vdd= 5v, 32khz - 20 40 ua idd2 slow mode (internal low rc, stop high clock) vdd= 3v, 16khz - 5 10 ua vdd= 5v, 25 c - 0.8 1.6 ua vdd= 3v, 25 c - 0.7 1.4 ua vdd= 5v, -40 c~ 85 c - 10 21 ua idd3 sleep mode vdd= 3v, -40 c~ 85 c - 10 21 ua vdd= 5v, 4mhz - 0.6 1.2 ma vdd= 3v, 4mhz - 0.25 0.5 ma vdd=5v, ilrc 32khz - 15 30 ua supply current (disable adc) idd4 green mode (no loading, fcpu = fosc/4 watchdog disable) vdd=3v, ilrc 16khz , - 3 6 ua 25 c, vdd= 5v, fcpu = 1mhz 15.2 16 16.8 mhz internal high oscillator freq. fihrc internal hihg rc (ihrc) -40 c~85 c, vdd= 2.4v~5.5v, fcpu = 1mhz~16 mhz 12 16 20 mhz vdet0 low voltage reset level. 1.7 2.0 2.3 v vdet1 low voltage reset level. fcpu = 1 mhz. low voltage indicator level. fcpu = 1 mhz. 2.0 2.3 3 v lvd voltage vdet2 low voltage indicator level. fcpu = 1 mhz 2.9 3.4 4.5 v vrefh1 external reference voltage, vdd = 5.0v. 2v - vdd v vrefh2 internal vdd reference voltage, vdd = 5v. - vdd* - v vrefh3 internal 4v reference voltage, vdd = 5v. - 4* - v vrefh4 internal 3v reference voltage, vdd = 5v. - 3* - v vrefh input voltage vrefh5 internal 2v reference voltage, vdd = 5v. - 2* - v ain0 ~ ain5 input voltage vani vdd = 5.0v 0 - vrefh1~5 v adc enable time tast ready to start convert after set adenb = ?1? 100 - - us i adc vdd=5.0v - 0.6 - ma adc current consumption vdd=3.0v - 0.4 - ma f adclk vdd=5.0v - 8m hz adc clock frequency vdd=3.0v - 5m hz
SN8P2711 8-bit micro-controller sonix technology co., ltd page 114 version 1.4 adc conversion cycle time f adcyl vdd=2.4v~5.5v 64 1/f adcl k f adsmp vdd=5.0v 125 k/sec adc sampling rate (set fads=1 frequency) vdd=3.0v 80 k/sec differential nonlinearity dnl vdd=5.0v , avrefh=3.2v, f adsmp =7.8k 1 2 16 lsb integral nonlinearity inl vdd=5.0v , avrefh=3.2v, f adsmp =7.8k 2 4 16 lsb no missing code nmc vdd=5.0v , avrefh=3.2v, f adsmp =7.8k 8 10 12 bits *these parameters are for design reference, not tested. ? internal 16mhz oscillator rc type temperature characteristic. power voltage (vdd) = 5v. machine cycle (fcpu) = fhosc/4. typical temperature = 25 c. typical internal 16mhz oscilla tor rc type frequency = 16mhz. testing temperature range = ?40 c ~ + 90 c typ. 25oc 13.00 13.50 14.00 14.50 15.00 15.50 16.00 16.50 17.00 17.50 -40-30-20-10 0 102030405060708090 temperature (oc) ihrc freq. (mhz)
SN8P2711 8-bit micro-controller sonix technology co., ltd page 115 version 1.4 ? internal 16mhz oscillator rc type power vo ltage and machine cycl e characteristic. temperature = 25 c. typical power voltage (vdd) = 5v. typical machin cycle (fcpu) = fhosc / 4. typical internal 16mhz oscilla tor rc type frequency = 16mhz. testing power voltage range (vdd) = 3v~5.5v. testing machine cycle range (fcpu) = fhosc/1~fhosc/16. typ. fcpu=fhosc/4 15.50 15.60 15.70 15.80 15.90 16.00 16.10 16.20 16.30 16.40 fhosc/16 fhosc/4 fhosc/1 machine cycle (fcpu) ihrc freq.(mhz) 3v 3.5v 4v 4.5v 5v 5.5v
SN8P2711 8-bit micro-controller sonix technology co., ltd page 116 version 1.4 1 1 1 2 2 2 development tool version 12.1 ice (in circuit emulation) z sn8ice 2k ice: full function emulates SN8P2711. ? sn8ice 2k ice emulation notice: a. operation voltage of ice: 3.0v ~ 5.0v. b. recommend maximum emulation speed at 5v: 8 mips (e.g. 16mhz crystal and fcpu = fhosc/2). c. internal 16m rc precision is bad than real chip. d. use SN8P2711 ev-kit to emulate lvd and adc reference voltage configuration. ? note: s8kd-2 ice doesn?t support SN8P2711 emulation. 12.2 otp writer z easy writer v1.0: ? otp programming is controlled by ice without firm ware upgrade suffers. please refer easy writer user manual for detailed information. ? in SN8P2711 otp programming by easy writ er, the crystal of ice must be 16mhz. ? connect easy writer to ice through a 60-pin cable which shipping with easy writer. z mp-easy writer v1.0: stand-alone operation to support SN8P2711 mass production. ? note: writer 3.0 doesn?t support SN8P2711 programming. 12.3 sn8ide sonix 8-bit mcu integrated development environment include assembler, ice debugger and otp writer software. z for sn8ice 2k: m2ide_v107or later. z for easy writer and mp-easy writer: m2ide_v107 or later ? note: sn8ide (sn8ied_1.99r?) and sn8w txxx don?t support SN8P2711 emulation.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 117 version 1.4 12.4 SN8P2711 ev kit 12.4.1 pcb description sonix provides SN8P2711 ev kit ver. a for function emulat ion. for SN8P2711 ice emulation, the ev kit provides adc internal reference voltage and lvd 2.4v/3.6v selection circuits. con1: i/o port and adc reference input. connect to sn8ice 2k con1. jp6: lvd 2.4v, 3.6v input pins. c onnect to sn8ice 2k jp6. s14: lvd 2.4v/3.6v control switch. to emulate lvd 2.4v flag/reset function and lvd 3.6v flag function. switch no. on off s7 lvd 2.4v active lvd 2.4v inactive s8 lvd 3.6v active lvd 3.6v inactive lvd36 lvd_3.6v_tp lvd24 lvd24 lvd36 lvd36 r29 100k r30 100k vdd lvd24 lvd_2.4v_tp vdd s14 sw dip-2 1 2 4 3
SN8P2711 8-bit micro-controller sonix technology co., ltd page 118 version 1.4 s16: adc reference voltage selection. the reference voltage is connected to vrefh pin of con1. the max. reference voltage is vdd. if vdd < int_vrefh_4.0v, the adc refere nce voltage is vdd. ext_vrefh is external reference voltage selection and input from p4.0. under internal referenc e conditions, p4.0 is general purpose i/o or adc analog input mode. r26: 2k ohm vr to adjust adc internal reference voltage. user have to correct internal reference voltage. set s16 to int_vrefh_4.0v mode, input power vdd = 5v, measure inter nal reference voltage from j3. adjust r26 to make j3 voltage = 4.0v. vdd r32 600 int_vrefh vin u2 lm431 vrefh v40 v20 int_vrefh_tp c8 10uf r33 1k vin int_vrefh int_vrefh r27 100 v20 vrefh verfh vin r31 200 vrefh v30 vrefh_tp s16 off on 1 2 3 4 5 6 12 11 10 9 8 7 vdd p4.0 c7 10uf v40 vrefh v30 r26 2k vrefh r34 2k r36, p37: r36=300k ohm, r37= 100k ohm. the bias voltage is equal to 1/4 vdd and emulates SN8P2711 internal 1/4 vdd voltage for low battery detector by adc channel 5. c9~c14: connect 47uf capacitors to ain0~ain5 input wh ich are adc channel 0~5 bypass capacitors. c15~c20: connect 0.1uf capacitors to ain0~ain5 input wh ich are adc channel 0~5 bypass capacitors. switch no. s1 s2 s3 s4 s5 s6 int_vrefh_2.0v on on off off off off int_vrefh_3.0v off on off off on off int_vrefh_4.0v off off on off on off int_vrefh_vdd off off off on off off ext_vrefh off off off off off on
SN8P2711 8-bit micro-controller sonix technology co., ltd page 119 version 1.4 12.4.2 SN8P2711 ev kit connect to sn8ice 2k the connection from SN8P2711 ev kit to sn8ice 2k is as following. the adc reference voltage is supplied by SN8P2711 ev kit. the avrefh/vdd jump pin of sn8ice 2k must be removed.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 120 version 1.4 12.5 transition board for otp programming 12.5.1 SN8P2711 v3 transition board SN8P2711 v3 transition board is for SN8P2711 otp programming including p-dip 14 pin, sop 14 pin and ssop 16 pin sockets connection. ) jp2: connect to ez or ez_mp writer. ) u1: p-dip 14 pin socket. ) u2: set sop 14 pin socket for SN8P2711s programming (using sop 16 pin socket : tx-sop16pin ).
SN8P2711 8-bit micro-controller sonix technology co., ltd page 121 version 1.4 ) u3: set ssop 16 pin socket for SN8P2711x programming (using ssop 20 pin socket : tx-ssop20pin ). 12.5.2 SN8P2711 mp028a transition board for ez/mpez writer SN8P2711 mp028a transition board is for ez and mpez writer supported SN8P2711 otp programming.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 122 version 1.4 12.5.3 SN8P2711 mp028a conn ect to ez_mp writer 12.5.4 SN8P2711 mp028a connect to ez writer
SN8P2711 8-bit micro-controller sonix technology co., ltd page 123 version 1.4 12.5.5 SN8P2711 v3 connect to ez writer 12.5.6 SN8P2711 v3 connect to ez_mp writer
SN8P2711 8-bit micro-controller sonix technology co., ltd page 124 version 1.4 12.6 otp programming pin 12.6.1 easy writer transition board socket pin assignment easy writer jp1/jp2 easy writer jp3 (mapping to 48-pin text tool) vss 2 1 vdd dip1 1 48 dip48 ce 4 3 clk/pgclk dip2 2 47 dip47 oe/shiftdat 6 5 pgm/otpclk dip3 3 46 dip46 d0 8 7 d1 dip4 4 45 dip45 d2 10 9 d3 dip5 5 44 dip44 d4 12 11 d5 dip6 6 43 dip43 d6 14 13 d7 dip7 7 42 dip42 vpp 16 15 vdd dip8 8 41 dip41 rst 18 17 hls dip9 9 40 dip40 alsb/pdb 20 19 - dip10 10 39 dip39 dip11 11 38 dip38 jp1 for mp transition board dip12 12 37 dip38 jp2 for writer v3.0 transition board dip13 13 36 dip36 dip14 14 35 dip35 dip15 15 34 dip34 dip16 16 33 dip33 dip17 17 32 dip32 dip18 18 31 dip31 dip19 19 30 dip30 dip20 20 29 dip29 dip21 21 28 dip28 dip22 22 27 dip27 dip23 23 26 dip26 dip24 24 25 dip25 jp3 for mp transition board
SN8P2711 8-bit micro-controller sonix technology co., ltd page 125 version 1.4 12.6.2 programming pin mapping: programming information of SN8P2711 series chip name SN8P2711p,s SN8P2711x ez writer connector otp ic / jp3 pin assigment number name number pin number pin 1 vdd 1 vdd 1 vdd 2 gnd 14 vss 16 vss 3 clk 9 p4.0 11 p4.0 4 ce - - - - 5 pgm 13 p4.4 15 p4.4 6 oe 10 p4.1 12 p4.1 7 d1 - - - - 8 d0 - - - - 9 d3 - - - - 10 d2 - - - - 11 d5 - - - - 12 d4 - - - - 13 d7 - - - - 14 d6 - - - - 15 vdd - - - - 16 vpp 4 rst 4 rst 17 hls - - - - 18 rst - - - - 19 - - - - - 20 alsb/pdb 3 p0.2 3 p0.2 ? note:use m2ide v1.06 (or after version) to simulation. ? note: use 16m hz crystal to simulation internal 16m rc. ? note: use 16m hz crystal to programming with ezwriter.
SN8P2711 8-bit micro-controller sonix technology co., ltd page 126 version 1.4 1 1 1 3 3 3 package information 13.1 p-dip 14 pin min nor max min nor max symbols (inch) (mm) a - - 0.210 - - 5.334 a1 0.015 - - 0.381 - - a2 0.125 0.130 0.135 3.175 3.302 3.429 d 0.735 0.075 0.775 18.669 1.905 19.685 e 0.300 7.62 e1 0.245 0.250 0.255 6.223 6.35 6.477 l 0.115 0.130 0.150 2.921 3.302 3.810 b 0.335 0.355 0.375 8.509 9.017 9.525 0 7 15 0 7 15
SN8P2711 8-bit micro-controller sonix technology co., ltd page 127 version 1.4 13.2 sop 14 pin min nor max min nor max symbols (inch) (mm) a 0.058 0.064 0.068 1.4732 1.6256 1.7272 a1 0.004 - 0.010 0.1016 - 0.254 b 0.013 0.016 0.020 0.3302 0.4064 0.508 c 0.0075 0.008 0.0098 0.1905 0.2032 0.2490 d 0.336 0.341 0.344 8.5344 8.6614 8.7376 e 0.150 0.154 0.157 3.81 3.9116 3.9878 e - 0.050 - - 1.27 - h 0.228 0.236 0.244 5.7912 5.9944 6.1976 l 0.015 0.025 0.050 0.381 0.635 1.27 0 - 8 0 - 8
SN8P2711 8-bit micro-controller sonix technology co., ltd page 128 version 1.4 13.3 ssop 16 pin min nor max min nor max symbols (inch) (mm) a 0.053 - 0.069 1.3462 - 1.7526 a1 0.004 - 0.010 0.1016 - 0.254 a2 - - 0.059 - - 1.4986 b 0.008 - 0.012 0.2032 - 0.3048 b1 0.008 - 0.011 0.2032 - 0.2794 c 0.007 - 0.010 0.1778 - 0.254 c1 0.007 - 0.009 0.1778 - 0.2286 d 0.189 - 0.197 4.8006 - 5.0038 e1 0.150 - 0.157 3.81 - 3.9878 e 0.228 - 0.244 5.7912 - 6.1976 l 0.016 - 0.050 0.4064 - 1.27 e 0.025 basic 0.635 basic 0 - 8 0 - 8
SN8P2711 8-bit micro-controller sonix technology co., ltd page 129 version 1.4 1 1 1 4 4 4 marking definition 14.1 introduction there are many different types in sonix 8-bit mcu production line. this note listed the produ ction definition of all 8-bit mcu for order or obtain information. this definition is only for blank otp mcu. 14.2 marking indetification system sn8 x part no. x x x title sonix 8-bit mcu production rom type p=otp material b = pb-free package g = green package temperature range - = 0 ~ 70 d = -40 ~ 85 shipping package w = wafer h = dice p = p-dip s = sop x = ssop device 2711
SN8P2711 8-bit micro-controller sonix technology co., ltd page 130 version 1.4 14.3 marking example name rom type device package temperature material SN8P2711pb otp 2711 p-dip 0 ~70 pb-free package SN8P2711sb otp 2711 sop 0 ~70 pb-free package 14.4 datecode system x x x x xxxxx year month 1=january 2=february . . . . 9=september a=october b=november c=december sonix internal use day 1=01 2=02 . . . . 9=09 a=10 b=11 . . . . 03= 2003 04= 2004 05= 2005 06= 2006 . . . .
SN8P2711 8-bit micro-controller sonix technology co., ltd page 131 version 1.4 sonix reserves the right to make change without further notic e to any products herein to im prove reliability, function or design. sonix does not assume any liabilit y arising out of the application or use of any product or circuit described herein; neither does it convey any license under its patent rights nor the rights of ot hers. sonix products are not designed, intended, or authorized for us as components in systems intended, for surgical implant into the body, or other applications intended to support or sustain life, or for any other applicati on in which the failure of the sonix product could create a situation where personal injury or death may occur. s hould buyer purchase or use so nix products for any such unintended or unauthorized application. buyer shall indemnify and hold sonix and its officers , employ ees, subsidiaries, affiliates and distributors harmless agai nst all claims, cost, damages, and expenses , and reasonable attorney fees arising out of, directly or indirectly, any clai m of personal injury or death associated with such unintended or unauthorized use even if such claim alleges that sonix was negligent regarding the design or manufacture of the part. main office: address: 9f, no. 8, hsien cheng 5th s t, chupei city, hsinchu, taiwan r.o.c. tel: 886-3-551 0520 fax: 886-3-551 0523 taipei office: address: 15f-2, no. 171, song ted road, taipei, taiwan r.o.c. tel: 886-2-2759 1980 fax: 886-2-2759 8180 hong kong office: address: flat 3 9/f energy plaza 92 gr anville road, tsimshatsui east kowloon. tel: 852-2723 8086 fax: 852-2723 9179 technical support by email: sn8fae@sonix.com.tw


▲Up To Search▲   

 
Price & Availability of SN8P2711

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X